cancel
Showing results for 
Search instead for 
Did you mean: 

SMP 3.0: POST method for more than one entry

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Experts,

As we came to know that POST, PUT, DELETE OData call functionality have been added in SMP 3.0 SP03 PL02 recently. And we are able to execute the same.

Now we are trying with implementing POST  method for more than one entry. We have tried with the below payload


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

         <d:DEPT_ID>136</d:DEPT_ID> 

         <d:DEPT_NAME>FINANCE</d:DEPT_NAME> 

         <d:DEPT_LOCATION>ITC-1</d:DEPT_LOCATION> 

      </m:properties> 

   </atom:content> 

   <atom:link rel="https://localhost:8084/gateway/odata/SAP/HSQLDBDEPT;v=1/DEPARTMENT" type="application/xml;type=feed" title="DEPARTMENT" href='self'> 

      <m:inline> 

         <atom:feed> 

            <atom:entry> 

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

                  <m:properties> 

                     <d:DEPT_ID>137</d:DEPT_ID> 

                     <d:DEPT_NAME>FINANCE</d:DEPT_NAME> 

                     <d:DEPT_LOCATION>ITC-1</d:DEPT_LOCATION> 

                  </m:properties> 

               </atom:content> 

            </atom:entry> 

         </atom:feed> 

      </m:inline> 

   </atom:link> 

</atom:entry>


But only 1st record is getting updated in the HSQLDB database not both. What do you suggest for this kind of scenarios how to POST more than one entry?

Rgrds,

JK

Accepted Solutions (1)

Accepted Solutions (1)

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

yes, it worked with BATCH request.

Request body:

--batch

Content-Type: multipart/mixed; boundary=changeset


--changeset

Content-Type: application/http

Content-Transfer-Encoding: binary

POST DEPARTMENT HTTP/1.1

Content-Type: application/atom+xml


<?xml version="1.0" encoding="utf-8" standalone="yes"?>

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

<d:DEPT_ID>136</d:DEPT_ID>

<d:DEPT_NAME>CanvasM</d:DEPT_NAME>

<d:DEPT_LOCATION>ITC-5</d:DEPT_LOCATION>

</m:properties>

</atom:content>

</atom:entry>

--changeset

Content-Type: application/http

Content-Transfer-Encoding: binary

POST DEPARTMENT HTTP/1.1

Content-Type: application/atom+xml

<?xml version="1.0" encoding="utf-8" standalone="yes"?>

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

<d:DEPT_ID>137</d:DEPT_ID>

<d:DEPT_NAME>CanvasM</d:DEPT_NAME>

<d:DEPT_LOCATION>ITC-5</d:DEPT_LOCATION>

</m:properties>

</atom:content>

</atom:entry>


--changeset--

--batch--

Answers (2)

Answers (2)

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

Update:

This issue still has not been resolved in latest release of smp 3.0 SP04 PL01

Regards

JK

midhun_vp
Active Contributor
0 Kudos

Hi Jitendra,

Batch requests allow you to group multiple Odata requests into single HTTP request.

GET, POST, PUT, DELETE requests can be added to a batch request. You have to manage it from the device code.

Ex.

private static final String ODATA_BATCH_VERB = "$batch";

...

//Create the Batch Request

BatchRequest mBatchRequest = new BatchRequest(appEndPoint + ODATA_BATCH_VERB);

mBatchRequest.setListener(this);

mBatchRequest.setPriority(IRequest.PRIORITY_HIGH);

//Create the Batch Request

mBatchRequest.addRetrieveRequestToBatch(getRequest);

mBatchRequest.addRequestToChangeset(deleteRequest);

mBatchRequest.addRequestToChangeset(createRequest);

mBatchRequest.addRequestToChangeset(updateRequest);

//Close change Requests

mBatchRequest.closeExistingChangeSet();

//Execute the batch request

requestManager().makeRequest(mBatchRequest);

Regards,

Midhun VP

Former Member
0 Kudos

Hi Jithendra,

Have you found a solution for the above problem? Right now I am also stuck with the same problem without any solution.

Regards,

Dhani

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

Unfortunately not.

I guess , can help us.

Rgrds,

JK

bjoernw
Employee
Employee
0 Kudos

Hi Jitendra,

as you are already in touch with my colleagues regarding this topic via email, we are going to follow up on you there.

Kind regards

Björn

agentry_src
Active Contributor
0 Kudos

Please post the solution here for others to utilize!

Thanks, Mike

SAP Customer Experience Group - CEG

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

This is still not resolved. I am keeping my eyes open, once get the solution will update the post.

Rgrds

JK