Using TASK API getSessionState with .net

Hello there!

One of the coolest things that MicroStrategy can do is the ability to embed reports/dashboards using URL API in  a portal, for example. You just have to copy the link of a report/document and paste it in an HTML code to display them. By default, the user needs to fill the login form to see the report/dashboard. If you don’t want that, you can insert 2 parameters in the URL: uid and pwd, so the user is automatically signed it.

Here is an example of URL API to display a specific dashboard:

http://localhost/MicroStrategy/asp/Main.aspx?evt=2048001&src=Main.aspx.2048001&visMode=0&currentViewMedia=2&documentID=68D3815340CDA9BF858B9EB715EC3A88&server=server1&Project=MicroStrategy%20Tutorial&port=0&share=1&hiddensections=header,path,dockTop,dockLeft,footer&uid=administrator&pwd=123456" width="1024" height="768" />

Everybody knows that using this approach wouldn’t be a good idea, because you show to everyone that sees the code an user to login to your projects. You can hide that login using TASK API. TASK API is an MicroStrategy API that uses Tasks (you can even create your own Tasks) to do some processes. To access TASK API page use one of these URLs:

For ASP.NET: http://localhost/MicroStrategy/asp/TaskAdmin.aspx

For J2EE: http://localhost/MicroStrategy/servlet/taskAdmin

You have to enter an OS (Operational System) user to login to this page. Once logged you have to:

1. Create a getSessionState link. To do that, just follow this TN:

2. If you are going to use .net with MicroStrategy Web ASP.NET , you can use this code below in your controller (just substitute the strings like username and password with your own data:

String url="https://localhost/MicroStrategy/asp/TaskAdmin.aspx?taskId=getSessionState&taskEnv=xml&taskContentType=xml&server=server1&project=tutorial&uid=administrator&pwd=thepassword";
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
request.Method = "GET";
request.UseDefaultCredentials = true;
request.PreAuthenticate = true;
request.Credentials = new NetworkCredential("username", "password", "domain");
// username and password are information about and Windows account, so you have to insert
HttpWebResponse response;
Stream stream;
StreamReader streamReader;
response = (HttpWebResponse)request.GetResponse();
stream = response.GetResponseStream();
streamReader = new StreamReader(stream);
string stringXml = streamReader.ReadToEnd();
String[] str = new string[] { "<min-state>", "</min-state>" };
string[] mstrSession= stringXml.Split(str,3, StringSplitOptions.None);

string url2 = "https://localhost/MicroStrategy/asp/Main.aspx?evt=2048001&src=Main.aspx.2048001&visMode=0&currentViewMedia=2&documentID=8AF8FCJHDY1234125CD&server=server1&Project=tutorial&port=0&share=1&hiddensections=header,path,dockTop,dockLeft,footer&usrSmgr=" + mstrSession[1];
return url2;

Just remember to use your report/document URL .

Just create a view to display this code.

Hope it helps.


God bless you!

11 thoughts on “Using TASK API getSessionState with .net

  1. Sergio

    Hello !!

    I created the session as you indicate and works perfectly. The problem is that after a while, the session expires and mstrSession stops working and asks again username and password in the embedded report.

    Have you been able to fix this somehow?


    1. Felipe Vilela Post author

      Hello Sergio!
      Thank you for the comment!

      You can go to Web Administrator -> Security -> Check: Allow automatic login if session is lost.
      You can also increase the idle web session in Developer -> Configure Intelligence Server -> Governing Rules -> General

      Hope it helps!


      1. smetech

        Hello again,

        many thanks for the tips!!. The first one we had already tried but not working, once a sesion expires it no longer reconnects. The second tip has not worked for us, we tried some values but the session also expires.

        thanks for the tips again and best regards 😉


  2. smetech

    Hi Felipe,

    Finally, following your idea, I’ve developed a code to call getSessionState function, through the aspx web, such as yours but instead of use a HttpWebRequest I’ve used a XmlTextReader and I’ve parsed the xml response to extract the code between min-state tag.

    Following this code, the session never expires because for each url access does a call to the getSessionState function.

    Thanks for help me!!
    Best regards,


  3. Pingback: Using TASK API getSessiongState with PHP « MicroStrategy Blog - Vilela's

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.