If you have used the MicroStrategy Task API’s reportDataService task, then you may be aware it has a limitation and will not work on reports that have a page-by. In this article I’m going to introduce you to a new plugin I have created using the MicroStrategy SDK named GetReportXMLorJSON.
The plugin zip file can be downloaded from my GitHub repository here. I’m guessing most of you reading this article probably already know how to install plugins but for those that do not, installing the plugin is pretty straight forward. To install the plugin, extract the contents of the zip file and copy the folder to the “plugins” folder located in your MicroStrategy web installation directory. For example, if you are using Tomcat, you would go to your MicroStrategy web server and copy the contents of the zip file to C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0\webapps\MicroStrategy\plugins. Next, you will need to restart your Tomcat or IIS web server for the changes to take effect.
Once you have the plugin installed, you can test the plugin by using the MicroStrategy TaskAdmin. The TaskAdmin is a nice tool for building and testing SDK URL’s. The URL for the Task Admin is http://localhost:8080/MicroStrategy/servlet/taskAdmin?pg=builder# (make sure you replace “localhost” with the host name or IP address of your web server. Next, click the tab labeled “Builder”. In the drop down box labeled “Task ID”, you should see the new plugin named “getReportXMLorJSON”. For this test we will have the new task return XML. Now, in the task envelope and task content type drop downs choose XML. Your screen should look similar to the below screen shot.
Next, we are going to enter the parameters. The first four parameters, ServerName, UserName, Password and Project are simply used to establish a connection to the project on your Intelligence Server. Next, you will need to enter the ReportID of the report you would like to execute. This can be obtained by viewing the properties of the report. The next parameter must be one of two values, either “xml” or “json” (without quotes). This will determine the format of the report results that will be returned by the task. Only enter a value for port if you know you are using something other than the default port. Finally, you have the option of expanding the page-by if the report has one. This is the key difference between this task and other out-of-the-box tasks that come with MicroStrategy as none of the out-of-the-box tasks that return XML or JSON can support reports with a page-by. I have confirmed this with MicroStrategy support. Lastly, enter values for prompts if required. Below is an example screen shot.
Once you are finished entering the parameters, click the button “Update URL”. This will build the appropriate URL in the below text box. This URL will be used to make the appropriate call to Intelligence Server. To execute the task, click the button labeled “Invoke URL”. This will use the URL to login to Intelligence Server, execute the report and return the results in the format we have specified. If all goes well, you should get XML results similar to the below screen shot with a status code of 200.