Friday, November 22, 2024

OIC - Handling Two Different Types of REST Responses in a REST API Call

Usecase:

When integrating with REST APIs using Oracle Integration Cloud (OIC), it's common to encounter scenarios where the API returns different response structures based on the outcome of the operation. 

For example:

Success Response: 

"success": 1,

"trans_suc_time":"" 

}

Failure Response: 

"success": 0, 

"error_code": "201"

 }

Managing such variations in response payloads can be challenging, but OIC provides several ways to handle this seamlessly. Here, we will explains how to effectively handle multiple response types in a single REST API integration.

Solution:
Create a unified Json payload using the above two types of response.

The unified json payload used:

"success": 0, 

"tranc_suc_time":"",

"error_code": "201"

 }

POC execution steps:

  1. Create REST Connections: Set up REST trigger and REST OIC self trigger invoke connections in OIC. 
  2. Build Integration 1.0.0: Create a REST-based integration with specific request and response payloads.
  3. Create new version 1.0.1 and Modify: Copy version 1.0.0, modify the response payload, and activate as version 1.0.1.
  4. Design an Invoker Integration: Create a new integration to use a unified payload and dynamically call either version (1.0.0 or 1.0.1), keeping only one active at a time.

Detailed poc screenshots:






















No comments:

Post a Comment

Featured Post

Types of encryption techniques

There are several types of encryption techniques used to secure data, each with its own use case and strengths: 1. Symmetric Encryption Us...