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?