I have a Java middleware where I have multiple users accessing TM1 and in Java I make rest calls to TM1 to get information. I am wondering if there's a way to retain TM1 sessions without closing them? For example, if User1 and User2 both access TM1, i only want a single session per user regardless of how many calls they make. Is that possible via cookie or session id or something? Thanks!
Hi,
how do you do the rest calls in your app?
I'm working on the same topic, i code a Win Form App in C# with TM1 connection for better planning/forecasting.
I started to import the Cubes and Dimensions in a treeview, first i can get all Cubes very easy with one call but then i use:
Parallel.ForEach (cubesList, cube =>
{
bool hasDimBranch = false;
reader = new JsonTextReader(new StringReader(rest.sendRequest("..../api/v1/Cubes(" + (char)39 + cube + (char)39 + ")/Dimensions?$select=Name")));
and here i create 1 session for every cube, i think i have to change my request type and use the sessionID (like webapps generate them in the cookie) to use the same session if its valid.
Edit:
I create a session like here:
public void InitializeTM1Connection(string adminhost, string username, string password, string Namespace = "")
{
camAuthString = Convert.ToBase64String(Encoding.UTF8.GetBytes(username + ":" + password + ":" + Namespace));
_adminhost = adminhost;
restClient.BaseUrl = new Uri(adminhost);
restClient.Timeout = -1;
restClient.RemoteCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;
var request = new RestRequest("Cubes", Method.GET);
request.AddHeader("Authorization", "CAMNamespace " + camAuthString);
IRestResponse response = restClient.Execute(request);
if (response.StatusCode == System.Net.HttpStatusCode.OK)
{
sessionCookie = response.Cookies[0];
}
lastStatusCode = response.StatusCode.ToString();
}
and save the sessionCookie (TM1SessionID), for the next calls i remove the auth header and pass the Sessioncookie as header.
Works fine!