Skip to main content

Oracle

Invoke Business Rule Using EPBCS REST API in Groovy – Part 1

EPBCS REST API

REST (Representational state transfer) API is a method to interact with the server using an HTTP request. The user sends an HTTP request and the server responds to the request in JSON Format. Before the REST API, the server used to send an xml response, which is processed on the client side, but now we use JSON, which is very lightweight compared to SOAP.

Step 1
Send the HTTP Request to EPBCS with Methods (GET,POST,PUT and DELETE) and Parameters.
For instance, if we want to execute a business rule then Method will be POST and Parameters will be the name of the business rule + parameters.
Note :
GET and POST are the common methods used by most of REST API.
PUT is used for Setting Daily Maintenance window
DELETE is specific to delete application snapshot.

Step 2
Receive a response in JSON format.
Note : Blog readers are expected to have basic knowledge of Java programming and understanding of REST API.

Oracle - Guide to Oracle Cloud: 5 Steps to Ensure a Successful Move to the Cloud
Guide to Oracle Cloud: 5 Steps to Ensure a Successful Move to the Cloud

Explore key considerations, integrating the cloud with legacy applications and challenges of current cloud implementations.

Get the Guide

Oracle has provided REST API, which can be directly used to do administrative tasks in Hyperion Cloud. EPM Automate is a good example of Rest API where EPM Automate internally calls REST API to do the administrative tasks. EPM Automate are very easy to use but have limited functionality when it comes to automation scripts. There may be few REST API which will be specific to FCCS,ARCS or Other EPM Cloud products, but there is lot of REST API in common that helps in automation. REST API can be written in many programming languages but this blog is explained in Groovy language.

Groovy
Groovy is a programming language that supports OOPS Concept and runs in Java platform. Groovy is more flexible (in my opinion) in writing automation scripts when compared to batch scripts. For instance assume we need to push metadata from an Oracle database to Cloud then groovy will be the right fit for this job as it can interact with external datasources. We have a lot of tutorials and blogs on Groovy which can help readers to understand the groovy language. I would suggest readers to have a glance on Groovy Tutorial.

Download and Install
1. Let’s Downland & Install the Groovy to start our first sample program in Groovy.
2. Download the java-json.jar file(Available on internet). This jar file has the libraries for parsing the data sent by server in JSON.

My First Program
After the successful installation of Groovy. Open the groovy console to execute our first groovy program.
1. Go to Program Files and click on GroovyConsole

2. I am not a big fan of Hello World or Hello Grovy programs so please copy the below program in the editor window.
*********************************************************
import org.json.JSONObject;
import groovy.json.JsonSlurper;
def executePrint
myString = new JSONObject().put(“PARAM_NAME”, “Value to be passed”).toString();
println myString;
executePrint;
null

*********************************************************

3. Click on the Execute Button


Above program explains how we will be passing Parameters to REST API.After Successful completion of groovy installation and execution of the sample program, We can start building our groovy program to invoke a Business Rule with parameters.

For better understanding I have split the script into 4 sections. Also it helps the developers to use the first 3 section of the code without any change(except the credentials) and update the section 4 based on client requirement. Most of the code explained in section 3 is taken from Oracle Common Helper Functions for Groovy.

1. Java classes to be used to read JSON data.
2. Setting variables for user credentials and authentication.
3. Common helper functions for Groovy provided by Oracle.
4. Main script to set the parameters and call the Business Rule.

I know it’s a lot of information with some Home Work to do, My next blog is continuation of this blog where I will be explaining the 4 sections in detail and we will see a demo on how to call the REST API to invoke a Business Rule.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Nesajosbenny Britto

More from this Author

Categories
Follow Us
TwitterLinkedinFacebookYoutubeInstagram