cancel
Showing results for 
Search instead for 
Did you mean: 

OData batch request with included services leads to error "400 Bad Request"

daniel_klink
Explorer

Hi all,

I have two OData services, where service A is included in service B such that the entity sets of service A are available in service B. I can use the URL for service B to make OData requests on objects of service A. So far so good. Now comes the Problem:

I want to use a $batch request on service B to do some POST operations on service A objects and then I want to do a GET operation on objects of service B. But it seems that in one batch request, it is not possible to access multiple services.

First, this is how the batch request body looks like for the request to service B:

--batch
Content-Type: multipart/mixed; boundary=changeset
--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary
POST ObjectOfServiceA HTTP/1.1
Content-Type: application/json
Accept: application/json

{"d":{ ... }}
--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary
POST ObjectOfServiceA HTTP/1.1
Content-Type: application/json
Accept: application/json {"d":{ ... }}
--changeset
----batch
Content-Type: application/http
Content-Transfer-Encoding: binary
GET ObjectOfServiceBSet HTTP/1.1
Content-Transfer-Encoding: binary
Accept: application/json
--batch--

And this is the response:

--1A4D3E35A859852802C3FC28D388D15A0
Content-Type: multipart/mixed; boundary=1A4D3E35A859852802C3FC28D388D15A1
Content-Length:  1664

--1A4D3E35A859852802C3FC28D388D15A1
Content-Type: application/http
Content-Length: 687
content-transfer-encoding: binary

HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 441
location: ...
dataserviceversion: 2.0

{"d":{...}}
--1A4D3E35A859852802C3FC28D388D15A1
Content-Type: application/http
Content-Length: 680
content-transfer-encoding: binary

HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 435
location: ...
dataserviceversion: 2.0

{"d":{...}}
--1A4D3E35A859852802C3FC28D388D15A1--

--1A4D3E35A859852802C3FC28D388D15A0
Content-Type: application/http
Content-Length: 900
content-transfer-encoding: binary

HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=utf-8
Content-Length: 780
dataserviceversion: 1.0

{"error":{"code":"/IWBEP/CM_MGW_RT/101","message":{"lang":"de","value":"Datenobjekt
 \"ObjectOfServiceB\" nicht 
gefunden."},"innererror":{"application":{"component_id":"","service_namespace":"/SAP/","service_id":"ServiceB","service_version":"0001"},"transactionid":"025E6B2B00C80030E005B61A5CBF7889","timestamp":"20180802102034.1571200","Error_Resolution":{"SAP_Transaction":"Run
 transaction /IWFND/ERROR_LOG on SAP Gateway hub system and search for 
entries with the timestamp above for more details","SAP_Note":"See SAP 
Note 1797736 for error analysis 
(https://service.sap.com/sap/support/notes/1797736)"},"errordetails":[{"code":"/IWBEP/CX_MGW_MED_EXCEPTION","message":"Datenobjekt
 \"ObjectOfServiceB\" nicht 
gefunden","propertyref":"","severity":"error","target":""}]}}}
--1A4D3E35A859852802C3FC28D388D15A0--

As you can see, the ObjectOfServiceB is not found in the data model. I can actually see in the code, that the Netweaver Gateway logik tries to find the ObjectOfServiceB in the model of service A.

If I reverse the order of the POST requests on service A and the GET on service B, the error changes such that the ObjectOfServiceA is not found.

It seems that if there is an included service, the code for instantiating the MGW runtime which contains the data model is just called for whatever service comes first in the batch request, but not for any subsequent service.

Does anyone have an idea on how to get around this?

Regards, Daniel

gregorw
Active Contributor
0 Kudos

Seems we need andre.fischer here :-).

Accepted Solutions (0)

Answers (0)