Skip to Content

Batch Update/Put on Gateway

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Jun 10, 2014 at 04:50 PM

    Hi Vivek,

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

    Thanks,

    Syam

    Add a comment
    10|10000 characters needed characters exceeded

    • 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--

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.