Getting Started with MicroStrategy TaskProc

The MicroStrategy Task Processor is a light weight interface for performing basic events over the web.  It’s an easier API to interface with than Web Services, but doesn’t come with all of the features.  If you just need a quick administrative task or just need the results of a basic report, it can be easier to get off the ground than Web Services or Java Web SDK.  Today I’ll do a quick walkthrough on how to use this (free!) method of MicroStrategy custom interaction.

The Task Processor (“TaskProc”) is a free component with the MicroStrategy Web installation that doesn’t require any additional licensing to use.  To use it, you simply invoke the URL and consume the result either in your program or manually if you need to.

Accessing the Task Processor
For MicroStrategy 9.0.1 and prior, you can access the TaskProc using the following URLs:

ASPx: http://servername/MicroStrategy/asp/taskproc.aspx
JSP: http://servername:port/MicroStrategy/servlet/taskProc

For MicroStrategy 9.0.2+, they changed the URL slightly:

ASPx: http://servername/MicroStrategy/asp/taskadmin.aspx
JSP: http://servername:port/MicroStrategy/servlet/taskAdmin

Getting a Session
The first thing to do no matter what task you want to perform is to get a session.  Just like when you connect with Web or Desktop, you need to first connect to the server before issuing commands.
When you navigate to the TaskProc, you can go to the Builder tab and use a simple GUI to generate the URL you’ll need to invoke.  In this case, you’ll want to choose getSessionState from the first drop down, and then your choice of envelope and content type (I usually go with xml).
Fill out the minimum information of server, project, user and password, and be sure to check the box next to each to include it.
Scroll to the bottom of the page, and click the Update URL button to receive your URL in the text box below.
Example:

http://servername/MicroStrategy/asp/TaskAdmin.aspx?taskId=getSessionState&taskEnv=xml&taskContentType=xml&server=ISERVER&project=PROJECT+NAME&uid=USER+ID&pwd=PASSWORD 

If you go to that URL with your web browser, you’ll see the XML return with your session information. the first piece returned under the <min-state> node is your Session ID.
Executing Your Task
Once you have your session, you can now execute your task.  In this example, I’ll run a report since that’s pretty simple and probably a popular task to run.  For a list of options, just peruse the Task drop down list.
  1. Paste the sessionState that was received from the previous TaskProc step (from the <min-state> node).
  2. Use the style ReportGridStyle (trust me) and provide the Report GUID you want to execute.
  3. Click the Update URL button at the bottom and you’ll end up with your ready to use URL.

Example:

http://servername/MicroStrategy/asp/TaskAdmin.aspx?taskId=reportExecute&taskEnv=xml&taskContentType=xml&sessionState=CONTENTS+OF+MIN-STATE+GOES+HERE&styleName=ReportGridStyle&reportID=REPORT_GUID

Answering Prompts

To answer prompts, append the appropriate strings to the end of the URL.
Value Prompts
&valuePromptAnswers=VALUE^VALUE
Multiple values can be passed, separated by a ^
Element Prompts
&elementsPromptAnswers=AttributeGUIDFirst;AttributeGUIDFirst:1;AttributeGUIDFirst:2,AttributeGUIDSecond;AttributeGUIDSecond:1;AttributeGUIDSecond:2

Multiple answers can be passed by separating AttributeGUID:Value pairs with a ;
Multiple prompts can be answered by separating each AttributeGUIDFirst with a ,

Conclusion
The TaskProc can be handy in a quick pinch, or be easier to get off the ground than the Web Services.  It’s pretty intuitive to use since it’s already setup and installed, and the Builder GUI does the heavy lifting for you.  I don’t use it in any day to day tasks, but if you have an interesting use for it, please share in the comments!

UPDATE: MicroStrategy TaskProc Enhancement in 9.2 SDK

You may also like...

30 Responses

  1. Kevin King says:

    Hey Bryan,
    I’m trying to get a large amount of data across the wire using the reportDataService, but it always times out (more than a minute). We plan to cache the report XML on the server for easier access, but where can we adjust the timeout?

    Thanks,
    Kevin

    • Bryan says:

      I’ve had that problem a few times, but haven’t found any fix for it aside from just caching the data and then trying again. I’m not aware of any time out settings from the SDK side, so it’s probably just a configuration on the web server if there is one.

  2. Kevin King says:

    You’re right – in fact I just needed to increase the read timeout of my WCF service that was calling it. (If you’re not calling it from a service, you need to add it to the HttpWebRequest object’s timeout property).

    We are pulling down a very large report data set, and it seems to take forever (much longer than a read from a table/cube should take).

    I’m also getting this exception when I try and do an elementsPromptAnswer… Have you seen it?

    WebBeanException encountered: com.microstrategy.web.beans.WebBeanException: Expected execution status 1, received status 2.

    Thanks Bryan!

  3. Arjun says:

    Which privilege do I need to have to access the TaskProc Admin console?

    Thanks Bryan

  4. Gaurav says:

    Hi,
    I want to execute task in my custom java application, wherein i want to execute report by using reportexecute task, how do i do it? please help me asap!!!

    Rgds,
    Gaurav

    • Bryan says:

      At that point, it’s just whatever the java code is to execute a URL and read it’s contents. I’m sure you can find that anywhere on the internet since it’s not unique to MicroStrategy. I’ve never done that in Java, because if I use Java, then I just use the MicroStrategy SDK to directly connect instead of bothering with the extra layer of TaskProc.

  5. Chirag says:

    This comment has been removed by a blog administrator.

    • Bryan says:

      The elementsPromptAnswer string should use the ; and : characters, not the %3B and %3A encoded versions. Also, you masked your webserver, but you didn’t mask your iserver, uid or pwd. I don’t think you can edit posts here, so I deleted it for you.

  6. tcorpchris says:

    Hi Bryan

    I was using the Task Admin export report function. It works fine for reports containing data.

    However when we choose dates such that the report has no data, putting the resulting URL into the browser results in a file I can save and read (a pdf merely stating the view contains no data).

    Putting the same URL through Visual studio (C#) produces a different file which Adobe reader states “There was a problem reading the document(14)”. Looking at the contents of the file, this version contains metadata on authors etc and differences in binary objects that the browser version did not.

    Any ideas on what might be corrupting the file?

  7. tcorpchris says:

    Another question…

    Is there anywhere we can get a more detailed description of each parameter than what is in the parameters tab?

    The reason I ask is I would like to periodically check if my session has expired, rather than just generate a new one. So I need to use the oldSession parameter (i think) but I do not know what to pass in.

    • Bryan says:

      Well, the above article shows two steps: Getting a session id and then executing a task. You can execute multiple tasks with the same session id. If the task returns an error (there’s a specific code for expired session, I don’t recall what it is), then just run the session id task first and then re-execute your other task. I don’t think you need to do pre-checking if the session is still active, but if you do, you could just try the getProjects task which is lightweight.

    • Bryan says:

      And I’m not aware of any more detailed explanations, but it could be in one of the manuals.

  8. Michał Sima says:

    This does not work properly in my case. I am using the following URL:

    XML
    […]
    <oi id=”5″ n=”Región” des=”” ab=””did=”8D679D4B11D3E4981000E787EC6DE8A4″
    tp=”12″ stp=”3072″ sta=”1073873279″ acg=”255″
    vr=”45E309D04AE1A3E1163E24BADCDD6B52″ icp=”” />
    […]
    <h ui=”1″ei=”BB:8D679D4B11D3E4981000E787EC6DE8A4:1:2:0:2:1:3:4:Central”
    rfd=”5″ dpt=”1″ rs=”1″ csp=”1″ o=”1″>
    <fv sm=”3″ class=”c3″>Central</fv>
    </h>
    […]

    URL

    http://localhost/MicroStrategy/asp/TaskAdmin.aspx?taskId=reportExecute&taskEnv=xml
    &taskContentType=xml&sessionState=[…]
    &styleName=ReportGridStyle
    &reportID=5E71925A411428F4EC24A9B28573D3AB
    &elementsPromptAnswers=8D679D4B11D3E4981000E787EC6DE8A4;8D679D4B11D3E4981000E787EC6DE8A4:Central

    or

    http://localhost/MicroStrategy/asp/Main.aspx?Server=localhost&Project=MicroStrategy+Tutorial&Port=0&evt=4001&src=Main.aspx.4001&reportID=5E71925A411428F4EC24A9B28573D3AB&elementsPromptAnswers=8D679D4B11D3E4981000E787EC6DE8A4;8D679D4B11D3E4981000E787EC6DE8A4:Central

    I have tried with various values. For example 8D679D4B11D3E4981000E787EC6DE8A4:4 instead of ‘Central’

    What can I be doing wrong?

  9. sn ng says:

    Hi , If we are using the SSO, and we have to invoke a RWExecute task how can we connect to a project?

    • sn ng says:

      I mean in case of SSO, we dont have the session state and also we dont have the password to get the session state
      So how can we execute any task and connect to project ?

    • Bryan says:

      If you are using a custom plugin for SSO, I’m not sure that you can. If you’re using an out of the box SSO, like NT Authentication, then I think there’s a connection type flag that you can set when getting the state.

    • sn ng says:

      we are using SiteMinder, yes we can set the authmode but does that mean before invoking any task we will have to execute the LoginTask to get the session state with auth mode for sso.

      Doesnt Microstrategy identify the sso request and if we can simply pass the project name as a parameter?

    • Bryan says:

      With TaskProc, you always have to pass the session state with the request. If you get the session state the first time, you can reuse it for subsequent requests as long as the session is valid. I think there’s a task to check if a session is valid or you could check for an error message coming back and then refresh the session state accordingly.

    • sn ng says:

      This comment has been removed by the author.

  10. sn ng says:

    Thanks Bryan !!

    I have some more questions around security 🙂

    1. Currently we are using RWexecute task to execute the report (for this we will invoke the session state using Login Task and authmode as 64).
    As a result of this we get the message id, which we then pass to browser and then using URL API we invoke the report.

    So here, we also needed to pass the same session state with the URL using usrSmgr parameter. We tried to invoke this url without sessionstate but we were getting the job expired error.

    Is it mandatory to pass the session state in mstr web url or there is any other option available.

    2. If this is mandatory, then what will be the consequences of sending the session state in the browser.
    I mean if user tries to execute other tasks which he is not privileged to using the session state he already received.

    Is there any sophisticated approach available for restricting the user from invoking the Tasks that they are not privileged to.

    3. We are using a servlet filter to restrict the users from invoking the events that they are not privileged to. is this a valid approach?
    Please note that we are using external prompts.

    Thanks in advance !!

  11. Bryan says:

    Session state is required in the URL. Security is handled by MicroStrategy just as if they’d tried to perform any given action through the UI. I wouldn’t worry about it, especially if your implementation is internal only. There isn’t a way for them to gain access to something they shouldn’t unless someone shares a URL that still contains an active session with elevated permissions. But even in that case, they could just as easily be sharing their username and password.

  12. Hi ,
    I given Task URL as
    http://servername:port/MicroStrategy/servlet/taskProc
    in Flex builder preferences still it showing me error as “The Task URL provided is incorrect.”

    Can any one help to sort out this Please?

  13. Roel Evers says:

    Thanks, been looking for a description of this functionality !

  14. Steven Jones says:

    I’m getting an XML response that says the following (below). Is there something that needs to be enabled on the server, or do I need different permissions that what works for logging into the application?

    errorMsg=”(Incorrect login/password.)” taskErrorCode=”-2147216959″>

    Is it also possible that we have an internal login that takes a hand-off from my user login in order to access the MSTR server?

  15. Filip says:

    Link to ‘ MicroStrategy TaskProc Enhancement in 9.2 SDK’ does not work

  16. Sumeet Gyanchandani says:

    http://servername/MicroStrategy/asp/main.aspx works fine, but http://servername/MicroStrategy/asp/taskadmin.aspx shows a blank page
    what could it be?

Leave a Reply

Your email address will not be published. Required fields are marked *