[OIC] Working with OAuth and Multi Part payloads in OIC

 


This post will show how to work with OAuth and multi-part APIs using OIC Integration.




First, Let's see how this looks in Postman. For this, I have created a collection "Multi Part API Demo" and have defined two variables:



  • access_token - stores the Auth Token received from Auth API. Auth API will return Bearer Token which will be used by Email API to send the emails.
  • hostname -stores the hostname of the API server like https://www.test.com. This is our Base URL for APIs.

APIs involved:

  • Auth API - {{hostname}}/oauth2/token A this will return Authentication Token which will be used by Email Send API. This API is using OAuth in which we will be passing the Client Id in username and Client Secret in Password for Authorisation
You can add a test script to automatically assign the response of this API to the access_token variable:

pm.test("Set Token", function () {
    var jsonData = pm.response.json()
    console.log(jsonData.access_token)
    pm.collectionVariables.set("access_token",jsonData.access_token)
});




  • Email API{{hostname}}/email/send This is MultiPart API which sends an email and takes multi-part payload



  • Define Connection TEST_REST_CONN   




Here we have kept the Security Policy as No Security and we can pass the OAuth Credentials in the Header Authorization tag. 


Authorization tag will have value as "Basic auth_tokenwhere auth_token will be the base64encode of "client_id:client_secret"

For Example, if client_id is xyz and client_secret is welcome1, then  base64encode of "client_id:client_secret" will be eHl6OndlbGNvbWUx and Authorization tag will be "Basic eHl6OndlbGNvbWUx"


So, in the integration, we can use this Connection as below which will return an Auth Token which will be used by Send Email API to send Emails. Select Configure Request Headers & Check Standard option




  • Now with the same connection add another REST Action in the integration, Make sure you select "Configure Request Headers" as we will use this to send multi-part payload i.e. form-data of API Request Body


  • Also, select both the below options:

  • Define Custom HTTP Headers as below if required



  • Add below mappings for Attachments:




 


  • Similarly, add mappings for Standard & Custom Headers
  • Now use Parameter List to construct Multi-Part Payload i.e. form-data of the request body:





Here, we have defined 6 parameters. There are two components of each parameter:

  1. Parameter Value - Maps directly to the Parameter element
  2. Parameter Name - Maps to name element 


The Mapper code will be like:



Comments

All Categories

Call Fusion BIP Report2 Change Password1 Code Combinations2 Compute Instance2 CTE1 Customer1 Data Aggregation2 Database5 Date Conversion1 DB Adapter2 Decryption1 Development1 EBS4 Encryption1 ESS Jobs3 Examine1 FBDI3 Fusion APIs1 Fusion BIP7 GIT2 GL3 GL Journals1 GL_DAILY_CONVERSION_TYPES1 GL_DAILY_RATES1 ICS1 Identity Domain1 Integrations1 Java1 Journal Import1 Keys1 Legal Entity1 LookupTypeLOV1 LOV1 LOVs1 MultiPartAPIs1 Networking1 NVL2 NVL in OIC2 OCI11 OCI Billing1 OCI Compute5 OCI Cost Management1 OCI Events Service1 OCI Free Tier3 OCI Notifification Service1 OCI Security3 OIC4 OIC Mapper2 Oracle26 Oracle ADF17 Oracle APEX1 Oracle Apps59 Oracle Apps R126 Oracle ATP1 Oracle BIP8 Oracle Cloud12 Oracle Cloud Free Tier1 Oracle cloud Infrastructure9 Oracle Cloud Security2 Oracle Cloud VM1 Oracle DB4 oracle ebs5 Oracle ERP4 Oracle ERP Adapter2 Oracle ERP Cloud7 Oracle financials2 Oracle Forms1 Oracle Fusion57 Oracle Fusion BIP4 Oracle Fusion ERP17 Oracle Fusion Financials18 Oracle Integration Cloud3 Oracle OAF17 Oracle OCI14 Oracle OIC22 Oracle SOA 12c10 Oracle SQL17 Oracle VBCS1 Oracle VBS2 Oracle Visual Builder Cloud Service1 Oracle Visual Builder Studio2 Oracle Workflow Notifications1 Others10 Payables2 Payables Import1 Properties1 R121 Register BIP as ESS Job1 Reset Password1 Responsibility1 REST4 Security List1 Site Map1 SOAP2 SOAP API2 SOAP UI3 SQL16 SQL Functions3 SQL Queries14 SQL Query8 SQL Tips3 SSH1 TCA1 Value Sets1 VBCS1 Virtual Machine2 Virtual Machines1 XML1 XSLT1
Show more