TM1 REST API Logout
Posted: Tue Mar 13, 2018 4:31 pm
Hello everyone!
I use JavaExtension in TI to read REST API data.
But all my connections through REST API generate separate session and finally (in TM1TOP) we have too many threads.
For closing REST API session we must use /api/logout and set TM1SessionId cookie for understanding of active session.
May be you have some examples of setting TM1SessionId cookie in Java, becouse i can't provide correct logout and session doesn't close.
My general connection code:
In this case sCookie = "TM1SessionId=vfGcaKVQ-_OsuHS-rMs0vw; Path=/api/; HttpOnly"
Then I try to make a logout and set TM1SessionId=vfGcaKVQ-_OsuHS-rMs0vw as cookie in new request:
But sCookie2="TM1SessionId=/; Expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; Path=/api/; HttpOnly"
What i'm doing wrong?
I use JavaExtension in TI to read REST API data.
But all my connections through REST API generate separate session and finally (in TM1TOP) we have too many threads.
For closing REST API session we must use /api/logout and set TM1SessionId cookie for understanding of active session.
May be you have some examples of setting TM1SessionId cookie in Java, becouse i can't provide correct logout and session doesn't close.
My general connection code:
Code: Select all
String url = "http://xxx:8000/api/v1/Threads";
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
String userCredentials = "JavaUser:apple";
String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());
con.setRequestProperty ("Authorization", basicAuth);
String sCookie = con.getHeaderField("Set-Cookie");
Then I try to make a logout and set TM1SessionId=vfGcaKVQ-_OsuHS-rMs0vw as cookie in new request:
Code: Select all
String url_Logout = "http://xxx:8000/api/logout";
URL obj_Logout = new URL(url_Logout);
con = (HttpURLConnection) obj_Logout.openConnection();
con.setRequestProperty("Cookie", sCookie);
String sCookie2 = con.getHeaderField("Set-Cookie");
What i'm doing wrong?