cancel
Showing results for 
Search instead for 
Did you mean: 

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

alvaro_blanco
Explorer
0 Kudos

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.

Andre_Fischer
Product and Topic Expert
Product and Topic Expert

If you again have to look for sample request you can have a look at the CORE_SAMPLES that we are delivering with SAP Gateway:

https://blogs.sap.com/2013/06/21/demo-test-cases/

Best Regards,

Andre

Accepted Solutions (1)

Accepted Solutions (1)

alvaro_blanco
Explorer
0 Kudos

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

hhllcks
Explorer
0 Kudos

Can you please answer the following questions:

  • What are your settings in SEGW for the function import?
  • Can you debug inside CHANGESET_BEGIN, CHANGESET_PROCESS and CHANGESET_END?
  • How do you create the request in UI5? (<- this is not so important, I think I could get this to work)

I am a little bit desperate at the moment because nothing seems to work.

I am at the point, where I have a request, that does not get rejected from the gateway. But breakpoints in CHANGESET_BEGIN and EXECUTE_ACTION do not work. It seems as if the gateway is doing nothing.

If I access the function import directly then it I get the error, that the HTTP method is not supported for the function import. But I chose POST in SEGW.

I chose the following settings in SEGW:

Name: ExampleFunctionImport
Return Type: EntityType
Return EntityType: ExampleEntity
Return Cardinality: 0...n
Return EntitySet: ExampleEntitySet
HTTP Method: POST
Action for Entity Type: ExampleEntity

Here is the request, that I created in the Gateway Client:

--batch
Content-Type: multipart/mixed; boundary=changeset
Content-Length: ###
--changeset Content-Type: application/http Content-Transfer-Encoding: binary
POST ExampleFunctionImport?DocumentId=guid'000C2924-ADF5-1ED6-B8C5-114D644A743D' HTTP/1.1
--changeset-- --batch--

Here is the answer from the gateway (HTTP Status 202 - Accepted):

--9CA6B637F41B3AA5F004A8A02A32E39C0
Content-Type: multipart/mixed
Content-Length: 0

--9CA6B637F41B3AA5F004A8A02A32E39C0--

What am I missing?

Really looking forward to an answer,

Hendrik

alvaro_blanco
Explorer
0 Kudos

Hi Hendrik,

just to state the obvious first:

  • Is the function import new?
  • Are you able to address the function import in "single" mode?
  • In case you aren't: is the function import visible in the metadata?
  • In case it isn't: have you refreshed the cache?

Regards,

Álvaro.

hhllcks
Explorer
0 Kudos

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?

Answers (0)