cancel
Showing results for 
Search instead for 
Did you mean: 

Integration with C4C OData API using CI

rrmalgi
Participant
0 Kudos

Hello Experts,

We have a scenario where we need to do a PATCH request with C4C OData API. This involves 2 steps in CI:

1. Fetch "Object ID" for a specific field Ex: Employee ID

2. Pass this "Object ID" in the URL

Only with the Object ID does the PATCH work successfully.

I know the ways to fetch object and do a patch call after this.

I specifically wanted to know how does this work when we have multiple employees to be updated.

Do we have to depend upon splitter/gather?

Please suggest

Best Regards

View Entire Topic
robertfels
Participant
0 Kudos

To update multiple employees using the C4C OData API, you can use a batch request. A batch request allows you to send multiple HTTP requests as a single HTTP request, which can include requests to create, update, and delete entities.

To create a batch request, you will need to use the HTTP "POST" method and send the requests in the body of the POST request. Each request in the batch should be separated by a double line break, and the requests should be specified using the OData batch format.

Here's an example of a batch request that updates multiple employees:

POST /sap/c4c/odata/v1/$batch HTTP/1.1
Content-Type: multipart/mixed; boundary=batch_123


--batch_123
Content-Type: application/http
Content-Transfer-Encoding:binary


PATCH Employees('123') HTTP/1.1
Content-Type: application/json


{
    "FirstName": "John",
    "LastName": "Doe"
}


--batch_123
Content-Type: application/http
Content-Transfer-Encoding:binary


PATCH Employees('456') HTTP/1.1
Content-Type: application/json


{
    "FirstName": "Jane",
    "LastName": "Doe"
}


--batch_123--

In this example, the batch request contains two requests to update employees with IDs '123' and '456'. You can include as many requests as you need in a single batch request.

You can use the splitter and gather patterns in your integration flow to separate the requests and process them individually, or you can use the batch request to update all the employees at once. It depends on your specific requirements and the capabilities of the integration platform you are using.