cancel
Showing results for 
Search instead for 
Did you mean: 

Batch Update/Put on Gateway

vivek_vishal
Advisor
Advisor
0 Kudos

Dear Experts,

I am trying to implement the Batch Update/Put for a scenario where the UI is sending multiple records in the PUT scenario. The Back end API can take multiple records to process the scenario but since this is an update (PUT) /ServiceName/EntityTypeSet('Key'), gateway is not able to take these concurrent requests at the same time.

To achieve this, the batch update was implemented and the following steps were performed.

1. Redefinition of Changeset_Begin and Changeset_End

2. Calling the Batch URL (sample type) /ServiceName/$Batch with the CSRF token for Content Type - multipart/mixed; boundary=batch and the payload of the following sample type.

3. Calling the POST in the Rest Client to perform the batch.

--batch

Content-Type: multipart/mixed; boundary=changeset

--changeset

Content-Type: application/http

Content-Transfer-Encoding: binary

PUT EntitytypeSet(Key='XXXXXXXXXX') HTTP/1.1

Content-Type: application/atom+xml

Content-Length: 975

<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

<atom:content type="application/xml">

<m:properties>

</m:properties>

</atom:content>

</atom:entry>

--changeset

Content-Type: application/http

Content-Transfer-Encoding: binary

PUT EntitytypeSet(Key='XXXXXXXXXX') HTTP/1.1

Content-Type: application/atom+xml

Content-Length: 975

<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

<atom:content type="application/xml">

<m:properties>

</m:properties>

</atom:content>

</atom:entry>

--changeset--

--batch--

I get the below error on the Rest Client.

Could not get any response

This seems to be like an error connecting to https://--------------/TechnicalServiceName/$batch. The response status was 0.
Check out the W3C XMLHttpRequest Level 2 spec for more details about when this happens.

Please advise.

Thanks in Advance.

Br, Vivek

Accepted Solutions (1)

Accepted Solutions (1)

SyambabuAllu
Contributor
0 Kudos

Hi Vivek,

Have you found any solution for this...If yes can you please share it.

Thanks,

Syam

vivek_vishal
Advisor
Advisor
0 Kudos

Hi Syam,

Previously the UI5 colleagues were applying the addBatchChangeOperations to an array of updates that was generating one change set ID for all batch operations. Later on the method was applied to create each batch operation separately so that each update had its own change set ID.

While the previous approach was not wrong the payload that was being sent was incorrectly formatted to suit that way.

To align with the above mentioned way of achieving this scenario the below mentioned sample payload worked.

.--batch_Id
.Content-Type: multipart/mixed; boundary=changeset_Id1
.
.--changeset_Id1
.Content-Type: application/http
.Content-Transfer-Encoding: binary
.
.PUT EntitySet('005056A505E31ED3AA90462E83EB6781') HTTP/1.1
.Accept-Language: en-US
.Accept: application/json
.MaxDataServiceVersion: 2.0
.DataServiceVersion: 2.0
.Content-Type: application/json
.Content-Length: 1207
.
.{Payload Content: Update 1}
.--changeset_Id1--
.
.--batch_Id
.Content-Type: multipart/mixed; boundary=changeset_Id2
.
.--changeset_Id2
.Content-Type: application/http
.Content-Transfer-Encoding: binary
.
.PUT EntitySet('005056A505E31ED3AA90462E83EB2781') HTTP/1.1
.Accept-Language: en-US
.Accept: application/json
.MaxDataServiceVersion: 2.0
.DataServiceVersion: 2.0
.Content-Type: application/json
.Content-Length: 1207
.
.{Payload Content: Update 2}
.--changeset_Id2--
.
.--batch_Id--

Answers (0)