Overview:

Java Spring Boot Framework Provides an easy way to Interact with the API. It can call any application Base API and process the Response according to our needs. This article explains how we can Invoke Anaplan Rest API using Java Spring Boot Frame Work.

Tools to be Installed

Java: Java 1.8 would be the preferred version.

Postman: This is a tool to test API’s.

STS: Spring Tool Suite (Preferred 3.9 Version).

List of Actions You Can Perform Using the Below Code

  • Upload file.
  • Run an import action. 
  • Run a process.
  • Run an export action.
  • Download file.
  • Run a delete action.

Before executing the code, we need to setup up a few parameters in the application.properties file including authentication credentials, workspace ID, and model ID.

To get the File ID, Import, Export, and Process ID, please refer the https://anaplan.docs.apiary.io/#.

karthik_kumar_0-1579937454709.png

  • Upload file.

File Upload needs a file ID and the data we need to upload as an input. Make sure the delimiter we have chosen in Anaplan is the same for the data we are uploading, separated by comma or tab, depending on what we have chosen in Anaplan.

Use the Below API to get the File ID:

https://api.anaplan.com/2/0/workspaces/8a81b09b599f391c0159be1157d87218/models/0D9B02A64229404A928D9...

karthik_kumar_0-1580227536131.png

  • Run an import action.

Once we have uploaded the file, the data needs to be reflected in the module. To achieve this, we need to run an Import Action. To run an Import Action, we need the Import Id. Get the Import ID using the below API, and use it in our Custom API. In response, we will get the Success Message after the import action has completed.

Use the Below API to get the Import Id:

https://api.anaplan.com/2/0/workspaces/8a81b09b599f391c0159be1157d87218/models/0D9B02A64229404A928D9...

karthik_kumar_1-1580227536138.png

  • Run a process.

We can run a process adding Import Action to the process. To run a process, we require Process ID. Get Process ID by using the below API, and use it in our Custom API. In response, we will get the Success Message once the process action has completed.

Use the Below API to get the Process ID:

https://api.anaplan.com/2/0/workspaces/8a81b09b599f391c0159be1157d87218/models/0D9B02A64229404A928D9...

karthik_kumar_2-1580227536149.png

  • Run an export action.

To run an Export Action, we need an Export ID, which we will get from Anaplan Export API. Once the Export Action has completed, it will send the Success Message. We can customize the code in a way to check whether Export has completed or not, by calling Action Status API.

Use the Below API to get the Export Id:

https://api.anaplan.com/2/0/workspaces/8a81b09b599f391c0159be1157d87218/models/0D9B02A64229404A928D9...

karthik_kumar_3-1580227536158.png

  • Download file.

Once the Export Action Completed, we can run the Download Action to download the latest file content. To download the file we, need to have the File ID, which we will get using the Anaplan Rest API.

Use the below API to get the File ID:

https://api.anaplan.com/2/0/workspaces/8a81b09b599f391c0159be1157d87218/models/0D9B02A64229404A928D9...

karthik_kumar_4-1580227536176.png

  • Run a delete action.

To perform Delete Action, we need Delete ID. Once Delete Action has performed, we will get a successful message.

Use the below API to get the Delete ID:

https://api.anaplan.com/2/0/workspaces/8a81b09b599f391c0159be1157d87218/models/0D9B02A64229404A928D9...

karthik_kumar_5-1580227536191.png

In a similar manner, we need to create end points for the source application and transform the data to our needs, and we can send data into Anaplan using the above approach. We can use the above implementation as an alternative approach for an integration solution, instead of using Integration tool.

Note: All the above implementations are to show how to call the Anaplan Rest API using java Spring Boot Framework. We can make it more customized for every action, depending on our needs of the application.

0 Kudos