Wednesday, 17 July 2019

Call External REST API: Oracle Integration Cloud

In this article, we'll show how to call External REST API in Oracle Integration Cloud using the REST Adapter.

Consider we need to consume the third party application REST API in OIC. The REST adapter will help to invoke external APIs.

For the time sake, we will consume the publicly available REST API in OIC. So let's get started and see how to call this.

Creating a REST Connection
  • Create a REST connection with name External_REST_Conn and select the Role as Invoke
  • Click the Configure Connectivity button, enter below details as below and click the OK button:
  • Click on the Configure Security button. From the popup, select the No security Policy from the Security Policy drop-down and click the OK button

Rest connection configuration is completed now. Just test the connection and Close

Create the Orchestrated Integration
  • Create an Orchestrated Integration
  • Drag and Drop the REST adapter(The REST adapter should be of Trigger type) as a Source and configure below properties from the first screen
    • What do you want to call your endpoint? GetTodos
    • What is the endpoint's relative resource URI: /mytodos
    • What action do you want to perform on the endpoint? GET
    • Select Configure this endpoint to receive the response checkbox
  • From the Response screen select below and click the Next button
    • Select JSON Sample from the Select the response payload format drop-down
    • Select the <<<inline>>> link, enter below JSON and click the Ok button
[
  {
    "MyUser": 1,
    "MyId": 2,
    "Mytitle": "My title",
    "IsCompleted": false
  }
]

  • Finish the REST wizard by clicking the Finish button
  • Drop the Rest adapter (External_REST_Conn) we created in the previous step ad configure  below properties from the first screen
    • What do you want to call your endpoint? CallTodos
    • What is the endpoint's relative resource URI: Enter the relative URL of the third party application REST API. In this case, it is /todos
    • What action do you want to perform on the endpoint? Since the third party service is of GET type hence select GET
    • Select Configure this endpoint to receive the response checkbox
  • From the Response screen select below and click the Next button
    • Select JSON Sample from the Select the response payload format drop-down
    • Select the <<<inline>>> link, enter below JSON and click the Ok button
This should match the exact JSON as we are getting response from the third party application REST API

[
  {
    "userId": 1,
    "id": 1,
    "title": "delectus aut autem",
    "completed": false
  },
  {
    "userId": 1,
    "id": 2,
    "title": "quis ut nam facilis et officia qui",
    "completed": false
  }
]

  • Finish the REST wizard by clicking the Finish button
  • Edit the GetTodos mapper and map fields as below
Source
Target
topLevelArray
topLevelArray
Userid
MyUser
Id
MyId
title
Mytitle
completed
IsCompleted


We are ready with the integration. Save, close and Activate the integration. Take the OIC REST API URL which got generated and hit the URL in the browser directly and check the response.


1 comment:

  1. Thank you so much for providing such a beautiful analysis of SQL and other aspects of REST API.

    SQL Server Load Rest Api

    ReplyDelete