on 2024 Nov 20 3:38 PM
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.
Request clarification before answering.
As @catano pointed out in his comment, the POST request was missing the header:
Accept: application/json
That solved the issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 18 | |
| 7 | |
| 6 | |
| 6 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.