Saturday 10 September 2016

PBCS REST API – Errors, wrong exceptions, MIME types and more…



Well, I had this query come to me whether it is possible to export data in a PBCS application in a custom format similar to a Planning data form… Now, if I was on the on-premise implementation of Hyperion, I would have jumped on EAS console and whipped out a report script and problem solved… Ah, but PBCS is not so kind… So, Data Management can be used to export data from PBCS, but the problem is it is in a relational format, which means I would need a new round of parsing to get the extract in shape… 

So, I logged into the Planning REST API and exportdataslice it is to see if I could get the data in the custom format…

Now this is me checking the latest version of the REST API for PBCS…In one of my previous blogs(http://exploitsinhyperion.blogspot.in/2016/08/hyperion-planning-rest-api.html) I had connected to the on-premise REST API, so now I am connecting to the PBCS…







The next snapshot has me listing down all the applications in the given instance… I have one application called MHPLAN1 



I now tried the exportdataslice command but I got an error as shown in the below snapshot saying “415 Unsupported Media Type”.




The error is because the browser does not know the MIME type of the response and hence it gives an unsupported media type exception. This can be fixed by adding a Content-Type:application/json to the header in the REST client as shown in the below snapshot.



If you observe the output of the query now as shown in the above snapshot, you will see that although the 415 error has been fixed, we have a new error namely, “The application name cannot be NULL”.

This was an interesting error since I had given an application name and yet it gave me an error saying that the application name is NULL.

The problem was this. The name of the Planning application is MHPLAN1. However, in the URL above I had given the application name as MHAPLAN1.

For some reason, the internal code resolved that the application name is NULL. (If you consider it, it makes sense… REST basically works on parameters for the networking environment. So when I send a query for an application X which does not exist, it will not give me an error saying application X does not exist. It will take the application name and check if it exists. If it exists, all is good in the world and it will return the application handle for subsequent processing. However, if the application does not exist, the default value of the application type is passed which I am assuming is NULL…Any query that runs against NULL will say that application name cannot be NULL… Java and its old NullPointerException)

Once, I corrected the above URL and replaced MHAPLAN1 with MHPLAN1, the exportdataslice query ran as expected… The output is in JSON tag format and if you are looking for a pure report output, you may need a round of cleanup…
 

No comments:

Post a Comment