Monday, 5 October 2015

Planning REST API part 2

In the last post I went through the core functionality available using the REST API in Planning, the post mainly focused on what is available in both on-premise  planning and PBCS.

I thought I would go through the some of the other REST resources which are only currently available in PBCS and these being around Lifecycle management.

If you have not read the last blog then I recommend doing so before reading this as it may not make much sense otherwise.

It is fair to say that most of the REST API functionality is also contained within the EPM automate utility but there may be situations where you don’t want to install the utility or you want to include access to the REST resources in your current business processes, it may also be the case where you want to script a process yourself.

As explained in the last post the planning REST resources are all accessed through the following URL structure:


To access the Lifecycle management resources then the URL structure is


To be able to find out the current API version then use a GET method with /interop/rest

I am once again using a REST client browser addin for demo purposes.

As the REST APIs require basic authentication I added my PBCS username and password to the header, the addin automatically encodes the username and password using base64.

The response was not what I was excepting as I definitely supplied the correct credentials.

The current REST API documentation and examples suggest that the username and password should be sent through the authorization header using basic authentication.

This threw me for a while until I watched the http traffic from the EPM automate utility and noticed that the format for the username should be:


Please note that is not my email address before you attempt to send mail to it :)

Since my post on the REST API Oracle have been in touch with me and have advised that the documentation will be updated in the future so you will not suffer the same pain :)

After updating the header to the correct format the results were much more pleasing.

From the JSON response you can see that the current API version is

To return information on the services that are available then the following resource can be accessed:


I am going to concentrate on the application snapshot resources as this is where the main LCM functionality resides and this includes:
  • Get Information about All Application Snapshots
  • Get Information about a Specific Application Snapshot
  • Upload/Download files or LCM snapshots to PBCS file repository.
  • List/Delete files in the PBCS file repository.
  • Execute an LCM import/export
I am going to start off with uploading a metadata file to the PBCS repository so that a job can then be run to import the metadata.

To upload a file there is a post resource available using the URL format:


{applicationSnapshotName} is the name of the file to be uploaded

The query parameters are:
chunkSize = Size of chunk being sent in bytes
isFirst = If this is the first chunk being sent set to true
isLast = If this is the last chunk being sent set to true.

The document does state the following:

The client calls the Upload REST API multiple times based on the size of file to be uploaded.
The client breaks the existing stream into a number of chunks, depending on the logic, so that each chunk size is not greater than 50 * 1024 * 1024 bytes.

I believe the size is based on the example code in the documentation which breaks the upload into 52mb chunks and is not the maximum size that can be sent in chunks.

It is all sounds more complex than it actually is, let me take an example using PowerShell to upload a csv file, I am using PowerShell like in my previous post because it does not require much code which is good for demo purposes and most should have easy access to it for testing.

Using the Invoke-RestMethod cmdlet makes life simple, pass in the URL, the encoded basis authentication header (using domain.username for the username), and the file to be uploaded.

The content type needs to be set to “application/octet-stream” otherwise it will not work.

The response LCM status codes are:
0 = success
-1 = in progress
Any other code is a failure.

Checking the inbox/outbox explorer confirms the file has been successfully uploaded

The only difference to download a file is that it is a GET method and there are no query parameters required like an upload, the format is:


You can also use the list files resource to return information about the files/folders in the PBCS repository.

This requires a GET method and the following resource URL:


There are two types, LCM which is usually an LCM snapshot (inbox/outbox/data are FDMEE related) and EXTERNAL which indicates the file is not LCM related.

The last modified time (which will need converting) and size is only relevant for EXTERNAL file types.

Deleting files is simple as well as there is a resource available using the DELETE method and following format:


Right back to my original task, first was to upload a metadata file which is done and next to execute a job to import the metadata.

I have a job already defined in the console which will import the csv file from the inbox into the product dimension.

I covered running jobs in the last post and it is the exactly the same concept to run an import metadata job.

Once the job ID has been stored you can check the status and also additional details about the job.

To clear any doubts the job console can be checked within the planning application.

Once the metadata has been loaded successfully you could execute another job to refresh planning by just changing the job type and job name.

Right let us move on to LCM export/import functionality which will repeat an export/import of an already defined snapshot

There are two post method resources available which use the following format:

LCM Export

LCM Import

So basically all you need to do is change the query parameter type depending on whether you are performing an export or an import.

To show how to use this functionality I am going to perform a repeat export of an LCM snapshot called LCM_PLANAPP

In all of my examples up to now I have put the full URL together depending on what resource I am executing which is fine but there is another to generate this by returning information about the snapshot.

I did use the resource earlier but did not show everything that can be returned, just to recap the resource to use is:

GET /interop/rest/{api_version}/applicationsnapshots/{applicationSnapshotName}

Depending on process you want to carry out on the snapshot you can return the full URL to use and the method.

I can put this into practice when running the LCM export.

The first section of the script returns all the information about the application snapshot.

The URL to run an export is then stored and used in the next REST call.

The LCM export status is displayed which is -1 so it is still processing.

The script waits for 10 seconds and then checks the status again which this time returns 0 which means it has completed.

To run an import all that would be required would to change “export” to “import” on line 18.

That pretty much covers most of the LCM REST functionality so you should now be able to upload/download/list/delete files, run LCM export/imports and combine with Planning jobs.

There are some REST resources available for FDMEE but I am going to cover them in a future post where I will look at possible options when using web services and FDMEE.

Monday, 28 September 2015

Planning REST API

If you have had any involvement with Oracle PBCS then you will know there is a utility called EPM automate that allows to remotely connect to a PBCS instance and run a whole host of tasks such as run rules, refresh the application, import and export metadata.

The utility is built on top of a set of REST (stands for Representational State Transfer) APIs using Java and is run from command line, the REST APIs can also be accessed outside of the utility using a variety of ways such as a web browsers or pretty much any programming language.

REST is not a new technology and there is lots of information out there on the internet if you want to read up and gain some knowledge.

Here is a brief description from the documentation:

REST describes any simple interface that transmits data over a standardized interface (such as HTTP) without an additional messaging layer, such as SOAP. 

REST provides a set of design rules for creating stateless services that are viewed as resources, or sources of specific information, and can be identified by their unique URIs. 

RESTful web services are services that are built according to REST principles and, as such, are designed to work well on the Web. Typically, RESTful web services are built on the HTTP protocol and implement operations that map to the common HTTP methods, such as GET, POST, PUT, and DELETE to retrieve, create, update, and delete resources, respectively.

As the majority of planning customers will either be on-premise or using alternative cloud provider I was interested to see if that REST APIs have actually made it to and if so what is available.

Before I start I will give the usual disclaimer and point out that the REST API is currently only documented for PBCS so I am not sure what you are about to read is supported yet which means  this is all for educational purposes :)

The URL structure to access planning REST resources is:


To test whether the API is there in there is a REST resource which uses a GET method and will return information about which REST API versions are available and supported.

The resource is accessed through /HyperionPlanning/rest and should return a response in JSON format, it may be worth having a read up on JSON if it means nothing to you.

So let’s just try and access the resource in a standard browser.

Nice, a response has been returned so the API is available in some form in

The JSON response may not be so easy to read but this is not a problem as there are a variety of REST client addons available for browsers.

For the examples I am going to use the RESTClient addon for Firefox which is extremely simple to use.

Enter the URL for the resource and the JSON response will be generated in a readable format.

The response parameters that are returned are defined as:

Deciphering the response indicates for the latest active version the URL to use for the resources will be:


If you are using PBCS it is currently


Let us look at another available resource to return a list of available applications.

This time the response is an error message and this is because I am trying to access a resource that requires authentication.

The majority of resources require HTTP basic authentication credentials to be supplied in the header which is no problem using the RESTClient

This will add the authentication credentials to header for all requests.

After adding the authentication header the response now returns the applications.

I think the response is clear enough to understand which applications are available, the dpEnabled parameter indicates whether the application supports decision packages which are part of the different planning modules such as public sector.

If you are using PBCS then the authentication is a little different which the documentation does not specify, maybe I will post an update soon.

Anyway, I thought I would show how to simple it is write a bit of code to work with the REST APIs, for my examples I have chosen PowerShell just because nowadays it is pretty much available on every client Windows machine and there is an IDE available so it will be easy to test, you can work with the REST APIs in most programming languages so pick the one that you are most comfortable with.

The first part of the script handles creating an encoded password for the HTTP header, once you have an encoded password this could be read from a file so no need to keep generating it.

Starting in Powershell V3 there is a included cmdlet called Invoke-RestMethod which sends http(s) requests to RESTful services and is extremely simple to use.

So with a small amount of code the list of available planning applications can displayed or stored.

If you are going to use the Planning REST API the main activity will be around the executing of Jobs.

The supported job types:
  • RULES 
There is a resource available to retrieve all the jobs that are available in the application using the following format:


This will return each job type and job name that is available in the requested application

If you only want to return certain job types then you can use a query parameter in JSON format:


Running a job once again has its own resource which this time uses the POST method:


In the body of the request you post the Job Type and the Job Name

This is where planning and PBCS seem to differ as in the PBCS version the body of the request accepts JSON but this doesn't seem to work in

I will go through examples of using this resource starting with refreshing the application.

In PBCS you can use the format of:


In order to be able to execute jobs in I used the following:


Once submitted this generated the following response:

The response parameters that are returned are defined as:

As you can see the status and descriptive status indicate the job is still running, to check the status of a job then there is another GET resource available using the following format:


This time the response confirms the refresh job was successfully completed.

If you look at the job console in planning you will also see the job information.

To achieve this using PowerShell is once again pretty simple.

The only difference from the earlier PowerShell example is this time it includes as body to the request.

As the Job ID has been stored it is easy to check the progress of the job.

To run a rule then the request is pretty much the same with only the job type and job name changing.

This is fine if the rules does not contain any runtime prompts, I couldn’t get it to work in when it does and I spent far long trying to get it to work.

I believe the format should be:

No matter what I tried I kept getting the following response:

The logs contained:

[APP: PLANNING#] [SRC_CLASS:] [SRC_METHOD: executeJob] Failed to run job: RestRule[[
at com.hyperion.planning.calcmgr.cmdlnlauncher.HspCalcMgrCmdLineLauncher.launchRule(

I am not sure whether it actually works in but if I do find out it does then I will update this post.

It certainly works in PBCS but like I said earlier that accepts JSON in the following format:

    "JobType": "JobType",
    "jobName": "JobName",
    "parameters": {
        "VariableName": "VariableValue"

I did find some interesting hidden resources that are not documented.

Please note the following is not available in PBCS and could be removed from on-premise in the future.

The first one returns the POV, Columns, Rows and data in a planning form.

The resource uses the GET method and can be accessed through:


Let us take this form as an example.

Submit the request.

This generates as response of:

Pretty cool the form and data have been returned in JSON, again this can be easily done in a scripting language.

There is another resource which is even more fascinating that allows MDX to be run against planning and produces a similar response to the last example.

The resource uses the POST method and can be accessed through:


In the body of the request the MDX can be passed.

The above MDX query should bring back data for a Smart List member and a text member.

Interesting the text member data is actually returned as the text string and not just a value, the Smart List data only returns the numeric value though.

To show how easy it is retrieve the data using a bit of scripting.

It certainly opens up lots of opportunities when you have easy access to the data.

There is also an additional query parameter that can be added which will also return attributes of the data cells in the response.

I think I am going to leave it there for today as putting this blog post together has certainly been a mammoth task and has taken up a lot of my time.

I am sure there will be future posts on this subject but in the meantime if you would like to know anything more just get in touch.