Create a REST API in OIC to insert multiple records in On-Prem Database using For Loop Concept

In this article, we will learn the concepts of FOR LOOP and utilize it to read the JSON payload to insert multiple records into the On-Prem database table. 



We will create a new integration with the name ForEachDBInsert  as shown in the snippet


 Click on Create




 Click the App Driven Orchestration 




 Provide the name  ForEachDBInsert 



Drop the rest connection trigger to the pallette


 



Provide the end point name 




Fill the response URI and Operation 








Click on JSON sample 



Copy the below sample code 

{
"UserData":[
        {
         "id":"",
         "firstname":"",
         "lastname":"",
"email":"",
         "qualification":""
      },
      {
         "id":"",
         "firstname":"",
         "lastname":"",
"email":"",
         "qualification":""
      }
  ]
}





Provide the JSON sample for the response as well 



JSON sample payload response 
{
"STATUS":""
}




Click on Next and then Done. 



Once rest trigger has been configured , next step is to drop For Each Loop 





Provide the For Loop Name and drag the array list of UserData as a repeating element in the ForLoop Configuration 




Now ForLoop has been configured, the next step is to drop the On-Prem database connector which will map with the request connector to iterate the records  and insert data into a database table 




Provide  the endpoint and select the operation as Run a SQL Statement 





enter the DML statement as shown in the snippet 



Click on Done 


Now next step is to start mapping between Forloop and On-Prem DB Connector 




Drag a mapper to capture the response 




create a filed to store the response 





Enable the tracking identifier 









Activate the integration 




Test the integration by providing the payload to insert data into the database 










Copy the payload pass it in the URL 

{
  "UserData": [
    {
      "id": "1",
      "firstname": "Keith",
      "lastname": "Walton",
      "email": "test123@oracle.com",
      "qualification": "Senior Integration Consultant"
    },
    {
      "id": "2",
      "firstname": "Tom",
      "lastname": "Cooper",
      "email": "test1245@oracle.com",
      "qualification": "OCI Consultant"
    },
    {
      "id": "3",
      "firstname": "Ram",
      "lastname": "Tiwari",
      "email": "xtest123@oracle.com",
      "qualification": "Principal Integration Consultant"
    },
    {
      "id": "4",
      "firstname": "Pranay",
      "lastname": "Tripathi",
      "email": "ytest1245@oracle.com",
      "qualification": "PAAS Consultant"
    },
    {
      "id": "5",
      "firstname": "Brent",
      "lastname": "Walton",
      "email": "test123@oracle.com",
      "qualification": "JAVA Cloud Consultant"
    },
    {
      "id": "6",
      "firstname": "Sheldon",
      "lastname": "Westman",
      "email": "test1245@oracle.com",
      "qualification": "IT ADMIN Consultant"
    }
  ]
}



Provide your OIC Credentials 







Query the table at an on-premise database instance to view the data






Comments

  1. Nice blog..

    Eduauraa ICSE Class 8 maths 2021 Syllabus for free and plan your study according to the syllabus. icse class 8 maths syllabus

    ReplyDelete

Post a Comment

Popular posts from this blog

Sample HZ API's script to Create Contacts and Contact Points in Oracle

REST integration built-in OIC to read Large files with size more than 10MB