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

Post request to /API_PRODUCT_SRV/A_Product is returning XML instead of JSON

frankrosales
Discoverer
0 Kudos
900

Hi community!

I'm using the API /API_PRODUCT_SRV/A_Product to create products via Http call. According to the API documentation (https://api.sap.com/api/OP_API_PRODUCT_SRV_0001/path/post_A_Product), the content of the response should be a JSON object in both success and error case scenarios, but I'm getting an XML response content.

I'm sending a JSON object in my request body and setting the content type header as "application/json". I have been able to successfully create products by sending POST requests to this end-point but I'm still receiving an XML object in the response content.

If I add the query parameter "$format=json" to my request URL, I get a Bad Request response saying that my request contains invalid parameters, but this time the response content is a JSON object.

What should I do in order to get a JSON response as described in the documentation.

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

frankrosales
Discoverer

As @catano pointed out in his comment, the POST request was missing the header: 

Accept: application/json

That solved the issue.

Answers (0)