One of the best things that have happened over the last few years for Oracle EPM consultants is the availability of REST APIs. I have written about it in my previous post on using Groovy and PBCS REST APIs.
However, today I wanted to present my experience on using Python and EPM REST APIs. This will be an introductory post and I will follow this up with a more detailed one. Leave a comment if you would like me to create a video tutorial about working with Python and EPM REST APIs.
REST APIs
I am sure you know about REST APIs. Here is a very generic explanation of it. A RESTful API, also referred to as a RESTful web service, is based on representational state transfer (REST) technology, an architectural style and approach to communications often used in web services development. It uses methods like GET, PUT, POST and DELETE.
You can read more about REST APIs here.
Why Use Python?
Python is one of the easiest programming languages to learn. I love the community of developers, the abundant resources and plethora of modules available for Python.
The request library is simply amazing. It is so easy to invoke REST APIs using the library and I assure you are going to love it. If you have not tried Python, I urge you to give it a chance.
Here are some useful Python resources:
Python Requests Package
We will be using the “requests” library to invoke the REST APIs. It is simple to use and has extensive documentation. Check out the documentation on the requests library.
To know more about all the Planning REST APIs available please visit Oracle Documentation.
The documentation is pretty good and you have example code for Java, Groovy and cURL.
Sample Programs
We will take a look at two sample programs. You can check out the gists given below or download the code from my github.
Get Version
Get the planning API version from the instance. Check out the below gist or the github code.
Lets talk about line number 8: response = requests.get(planning_url,auth=HTTPBasicAuth(uname,password),headers = headers)
- We use the requests.get() method to invoke the API and then fetch the API version from the planning instance
- The user name and password are encrypted and passed
- headers is set to {‘Content-Type’:’application/json’}
- planning_url has a value of https://<SERVICE_NAME>-<TENANT_NAME>.<SERVICE_TYPE>.<dcX>.oraclecloud.com/HyperionPlanning/rest/
- replace <SERVICE_NAME>, <TENANT_NAME>, <SERVICE_TYPE>, <dcX> with your values
Get Application Name
Get the application name from the instance.
- rest_end_point has a value of https://<SERVICE_NAME>-<TENANT_NAME>.<SERVICE_TYPE>.<dcX>.oraclecloud.com/HyperionPlanning/rest/v3/applications
- v3 is the planning API version
- replace <SERVICE_NAME>, <TENANT_NAME>, <SERVICE_TYPE>, <dcX> with your values
Things to keep in mind
- username should be passed as “domain name.username”
- headers should be set to {‘Content-Type’:’application/json’}
Here is the output from the script
I chose python since it is open source, easy to learn and code. Let me know if you have question on this.
Questions? Comments? Suggestions? Let us know!! Like / Subscribe / Follow for more updates.