Thursday, January 21, 2021

Running OIC REST Api cURL Script For CICD From Windows Command Prompt

Oracle has provided rest API for OIC(Oracle Integration Cloud).

We can leverage these API to pause, resume, activate, deactivate, run ,export and import integrations.

In the example we will see how we can achieve this using the windows CMD.

1). Activate an Integration:

Format:

curl -X POST -H 'Authorization: Bearer access_token' -H "Content-Type:application/json" -H "X-HTTP-Method-Override:PATCH" -d @update.json https://integration.us.oraclecloud.com/ic/api/integration/v1/integrations/HELLO_WORLD%7C01.02.0000


Example:

curl -X POST -u username:password -H "Content-Type:application/json" -H "X-HTTP-Method-Override:PATCH" -d @activate.json https://xx-instance-zzx-ia.integration.ocp.oraclecloud.com/ic/api/integration/v1/integrations/XXAPINV_MAIN%7C01.00.0000

The file activate.json : For enabling tracing use "payloadTracingEnabledFlag" as true

{"status":"ACTIVATED",
"payloadTracingEnabledFlag":true}


How to Run this command:

Go to windows search 



Now search for cmd




Make sure the file activate.json is there in the directory in which you are running the script.
Here we have in "C:\Users\Sumit.Kumar17\Downloads>" directory, so we have put the activate .json file here.




Now copy the cURL script and paste to CMD



The successful Response will be like below:



Now to Run Multiple script at one time we can write as below:

Use "&" between the two scripts as shown below->

curl -X POST -u username:password -H "Content-Type:application/json" -H "X-HTTP-Method-Override:PATCH" -d @activate.json https://xx-instance-zzx-ia.integration.ocp.oraclecloud.com/ic/api/integration/v1/integrations/XXAPINV_MAIN%7C01.00.0000 &
curl -X POST -u username:password -H "Content-Type:application/json" -H "X-HTTP-Method-Override:PATCH" -d @activate.json https://xx-instance-zzx-ia.integration.ocp.oraclecloud.com/ic/api/integration/v1/integrations/XXAPINV_CB%7C01.00.0000