cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

JSON deep insert returns atom/xml

rpanneel
Participant
0 Likes
1,963

Dear,

When I test a json deep insert (For eaxmple:a POST on /sap/opu/odata/sap/<Gateway_service>/<GW_Data>Set in the GW Client then it returns the result in atom/xml....

If i add ?$format=json to the call i receive following error:

The Data Services Request contains SystemQueryOptions that are not allowed for this Request Type

Is there a way to get the response in json for a POST deep insert/create?

Thanks in advance!

Kind Regards,

Robin

Accepted Solutions (1)

Accepted Solutions (1)

lukasz_grochal
Participant
0 Likes

A simple trick to get a json response from a POST request when testing with either the Gateway Client or any browser-based REST Client is to add the following header to the request:

Accept          application/json

No need to use $batch in this case unless you're really batching requests.

You can use this with any HTTP method supported.

ChandrashekharMahajan
Active Contributor
0 Likes

Hi Lukasz,

This was excellent! I was not aware on this. Thanks for sharing

Regards,

Chandra

Former Member
0 Likes

How will we use the POST method for deep entity if we have multiple level of associations.

/sap/opu/odata/SAP/ZCREATE_SALES_ORDER/SOHeaderSet?$expand=NavToItem,NavToHTexts,NavToItem/NavToSllines,NavToItem/NavToTexts

It is giving error:

The Data Services Request contains SystemQueryOptions that are not allowed for this Request Type

The same link works for GET but not for POST.

The association is linked as :

1. Header to Item.   (NavToItem)

2. Header to Header Texts. (,NavToHTexts)

3. Item to Schedule Lines. (,NavToItem/NavToSllines)

4. Item to Item Texts (NavToItem/NavToTexts)

Answers (1)

Answers (1)

ChandrashekharMahajan
Active Contributor
0 Likes

Hi Robin,

This error is coming from method PROCESS_ENTITY_SET (/IWCOR/CL_DS_PROC_DISPATCHER)

Below system query options are not allowed for POST.


" system query option are not allowed

         IF io_uri->expand IS NOT INITIAL OR

            io_uri->select IS NOT INITIAL OR

            io_uri->filter IS BOUND OR

            io_uri->orderby IS BOUND OR

            io_uri->skip IS NOT INITIAL OR

            io_uri->top IS NOT INITIAL OR

            io_uri->skiptoken IS NOT INITIAL OR

            io_uri->inlinecount IS NOT INITIAL OR

            io_uri->format IS NOT INITIAL.

           RAISE EXCEPTION TYPE /IWCOR/cx_DS_proc_error

             EXPORTING

               textid = /IWCOR/cx_DS_proc_error=>invalid_system_query_option.

ENDIF.

May be using batch call you can get response in JSON format. I mean using batch method, 1st give call to POST and then to GET which allows $format.

again on client side (may be ui5), you can easily convert response in json format with available APIs.

Regards,

Chandra