Skip to Content
avatar image
Former Member

How to make a batch changeset HTTP body call for POST Function Import?

I am trying to make a batch call to a function import with method POST and I am getting the following error:

The specified HTTP method is not allowed for the resource identified by the Data Service Request URI

When I call the function import in a single call it works so I guess the issue is in how I am trying to address it as a batch call.

My HTTP URL:

/sap/opu/odata/SAP/ZMYSERVICE_SRV/$batch

My HTTP request header:

Content-Type: multipart/mixed; boundary=batch

My HTTP request body:

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


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


POST PutSomethingIntoSomeplace?ThingID='00000190111201000001'&PlaceID='0000309893'

POST PutSomethingIntoSomeplace?ThingID='00000190111201000002'&PlaceID='0000309893'


--changeset--
--batch--

I have also redefined methods:

/IWBEP/IF_MGW_APPL_SRV_RUNTIME~CHANGESET_BEGIN

/IWBEP/IF_MGW_APPL_SRV_RUNTIME~CHANGESET_END

/IWBEP/IF_MGW_APPL_SRV_RUNTIME~CHANGESET_PROCESS

Thanks in advance.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Jan 31, 2017 at 11:18 AM

    My bad: it seems it was (as usual) a formatting issue in the request body. I'll leave it here before I close the question, in case someone may find it useful:

    --batch
    Content-Type: multipart/mixed; boundary=changeset
    
    --changeset
    Content-Type: application/http
    Content-Transfer-Encoding: binary
    
    POST PutSomethingIntoSomeplace?ThingID='00000190111201000001'&PlaceID='0000309893' HTTP/1.1
    
    --changeset
    Content-Type: application/http
    Content-Transfer-Encoding: binary
    
    POST PutSomethingIntoSomeplace?ThingID='00000190111201000002'&PlaceID='0000309893' HTTP/1.1
    
    --changeset--
    
    
    --batch--
    

    It's kind of a hell when you are trying to test this sort of things in the Gateway Client and you have no js library at hand to format the request...

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      I created a testservice to test further.

      It is possible to use the function import alone by calling

      POST /sap/opu/odata/SAP/Z_GW_TEST_SRV/DoWhateverInPost?Par1="Test"&Par2="Test2"
      

      The breakpoint in EXECUTE_ACTION is triggered.

      If I try to call

      POST /sap/opu/odata/SAP/Z_GW_TEST_SRV/$batch

      with the following request body

      --batch
      Content-Type: multipart/mixed; boundary=changeset
      
      --changeset
      Content-Type: application/http
      Content-Transfer-Encoding: binary
      
      POST DoWhateverInPost?Par1='Blabla'&Par2='BluBlu' HTTP/1.1
      
      --changeset
      
      Content-Type: application/http
      Content-Transfer-Encoding: binary
      
      POST DoWhateverInPost?Par1='Blabla'&Par2='BluBlu' HTTP/1.1
      
      --changeset
      --batch--

      NOTHING happens.

      However I get the following response (202):

      --69B16AD14CC8982FD6CA01193EF335370
      Content-Type: multipart/mixed
      Content-Length: 0
      --69B16AD14CC8982FD6CA01193EF335370--

      The metadata of the function import looks as follows:

      <FunctionImport Name="DoWhateverInPost" EntitySet="Tests" m:HttpMethod="POST" ReturnType="Z_GW_TEST_SRV.Test" sap:action-for="Z_GW_TEST_SRV.Test">
      
      <Parameter Name="Par2" Type="Edm.String" Mode="In"/>
      <Parameter Name="Par1" Type="Edm.String" Mode="In"/>
      
      </FunctionImport>

      I refreshed the metadata multiple times.

      Can you please post how your function import looks in SEGW?