hana odata batch

sap 博客有写

odata batch 处理前,先看一张图

 

In this blog post,we are going to see how to send a Odata Batch Request to the SAP Cloud for Customer system using POSTMAN Tool.

Answers to expect from this post?

  1. How to use batch request in the POSTMAN Tool
  2. What all are the Pre-requisites needs to be done before making a batch call.
  3. What is the format we need to follow in a batch Payload.
  4. What all are the header details needs to be maintained.

Lets get started:

Step 1 :

Login to the Postman Tool using your credentials.

In the Authorization Tab, Enter your credentials as below:

Step 2 :

The Next step is to fetch the CSRF Token.

CSRF Token is necessary in order to update or create the records in the C4C System.

For a GET Call, you don’t need a CSRF Token.

In order to get the CSRF Token,Go to the Header Tab.

Enter ‘x-csrf-token’ in the key and ‘Fetch’ in the Value as below:

After this, you have to make a get call to the C4C System.
Choose the action as GET and enter the URL to make the GET call to C4C System.

URL :

https://myXXXXXX.crm.ondemand.com/sap/c4c/odata/v1/c4codataapi/ServiceRequestCollection(‘YYYYYYYYYYY’)

XXXXXX – Tenant ID
YYYYYYYYYYYYY – Object id of a particular record in the Service Request Collection.

Note: You can use any collection to get the CSRF Token.

Once the GET Call is made, Go to the Headers Tab and Copy the x-csrf-token.

Now, navigate to the Top Header Tab and Paste the CSRF Token as below:

We have completed the Pre-requisite to post a record in the system.

Step 3 :

Now, we are going to create 3 Service Requests in the system in a single batch call.

Choose the Action as POST and enter the URL as below:

https://myXXXXXX.crm.ondemand.com/sap/c4c/odata/v1/c4codataapi/$batch

In case of batch call, you don’t need to mention the Collection name as you will mention the collection name in the Payload.

Go the Tab Body and Choose raw.

Copy paste the below Sample Payload.

This Payload will create three Service Requests in the System. We are passing only the Name field to create a record in the system, as it is the only mandatory field to create a Service Request.

Sample Payload for creating three records in the Batch Call :

--batch
Content-Type: multipart/mixed; boundary=changeset

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

POST ServiceRequestCollection HTTP/1.1
Content-Type: application/json
Content-ID: 2
Content-Length: 10000

{
"Name":"Testing 1"
}

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

POST ServiceRequestCollection HTTP/1.1
Content-Type: application/json
Content-ID: 2
Content-Length: 10000

{
"Name":"Testing 2"
}

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

POST ServiceRequestCollection HTTP/1.1
Content-Type: application/json
Content-ID: 2
Content-Length: 10000

{
"Name":"Testing 3"
}

--changeset--
--batch--

It is important to maintain the content type in the Header, for the system to recognize the Payload.

Once you add the Payload and the Headers, Click “SEND’ to send the request to the C4C System.

The request is successful, only when you receive a response back as below:

Conclusion:

If you get any error or if you are not getting any response back, check the below points :

  1. The Payload is Space Sensitive, it is mandatory to maintain the proper spacings.
  2. You are opening the Payload with –batch and it should be closed with –batch—
  3. The Changeset needs to be used only if you are changing the data in the database using POST, PATCH, PUT.
  4. Changeset is not required to fetch a data from the database.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值