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.

https://gist.github.com/99d943b514e1d30de93aee03fae776a6

Lets talk about line number 8: response = requests.get(planning_url,auth=HTTPBasicAuth(uname,password),headers = headers)

Get Application Name

Get the application name from the instance.

https://gist.github.com/raj-arun/2afc20c6d115bd0d0e7c9ea0413c6276

Things to keep in mind

  1. username should be passed as “domain name.username”
  2. headers should be set to {‘Content-Type’:’application/json’}

Here is the output from the script

Script Output

I chose python since it is open source, easy to learn and code. Let me know if you have question on this.

Leave a Reply

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