Sitemap

Sample REST service

3 min readOct 18, 2024

--

The most commonly used feature in OIC is invoking external REST APIs. In this blog, lets see how to invoke an external REST API from OIC integration which in turn is also a REST service.

The requirement is to invoke a public REST API and return the response received.

Steps to invoke an external REST API :

Create a new connection:

Create a connection using REST adapter with the name ‘Test_PublicREST’ and Role as Invoke.

Give the below values while configuring the connection:

Connection Type: REST API Base URL

Connection URL: https://api.restful-api.dev

Security Policy: No Security Policy (since this is a public API, we dont have any security policy).

Access Type: Public gateway.

Click on the buttons ‘Save’ and then ‘Test’

Create another new connection with the name=Trigger_REST Role=’Trigger’ and Security_Policy=’Basic Authentication’.

Press enter or click to view image in full size

Create a new Integration :

Click on Create button in the Design-> Integrations page.

Select the pattern ‘Application’ and provide the below values:

Name = ‘Test APIDev REST’

  1. Select Trigger_REST connection in the Trigger action by clicking on the + icon in the integration canvas.
  2. Configure the below:

What do you want to call your end Point? TriggerObjects (Any name for the trigger action)

What is the endpoint’s relative resource URI ? /getPhones

Get Manikanta kumar K’s stories in your inbox

Join Medium for free to get updates from this writer.

Select “Configure the endpoint to receive the response”.

Press enter or click to view image in full size

(Note: Select the checkboxes as per the requirement.

Add and review Parameters for this endpoint — Select this check box if you want your integration to accept any parameters)

Configure a request payload for this endpoint — This is applicable for POST, Patch, PUT operations and when you need the integration to accept any request payload).

3. Invoke the REST service (https://api.restful-api.dev/object):

Click on the + icon after the Trigger action and select the connection “Test_PublicRest” and provide the below values:

What do you want to call your end Point? InvokeApiDev (Any name related to the invoke action)

What is the endpoint’s relative resource URI ? /objects (specific uri that is to be invoked).

Configure this endpoint to receive the response.

Add an inline sample response in json format:

[
{
"id": "1",
"name": "yyPixel 6 Pro",
"data": {
"color": "Cloudy White",
"capacity": "128 GB"
}
},

{
"id": "13",
"name": "xxiPad Air",
"data": {
"Generation": "4th",
"Price": "519.99",
"Capacity": "256 GB"
}
}
]

4. Any changes in the request can be done in the map before “InvokeApiDev”.

5. Map the response from InvokeApiDev to integration response using the TriggerObjects Map.

Press enter or click to view image in full size

6. Click on the Business Identifiers icon at the right hand side and provide identifiers to monitor the instances.

7. Clicking on the Save button changes the integration status from Draft to Configured.

8. Go back to Integrations page and activate the integration in debug mode.

Testing:

9. Click on run action under the menu related to the integration.

Press enter or click to view image in full size

10. The executed flow and activity stream can be viewed by clicking on the instance Id also.

--

--

Manikanta kumar K
Manikanta kumar K

Written by Manikanta kumar K

17+ Years of experience in IT industry | Oracle Cloud Integration Specialist | OCI | Certified OCI Architect, Developer, Operations Professional