0
votes

We are facing an issue while sending json data to an external api using CL_HTTP_CLIENT. The JSON data is produced using '/ui2/cl_json=>serialize( data = ls_body compress = abap_true pretty_name = /ui2/cl_json=>pretty_mode-camel_case )' .

when sending this JSON as data the the external api returns status 400 with response as { "errorCode": "INVALID_REQUEST_BODY", "message": "The request body is missing or improperly formatted. Unexpected character encountered while parsing value: \u001f. Path '', line 0, position 0." } .

we also stringyfied this JSON Data in backend as it might be due to parsing error but it didnt work. The same stringyfied data tried to send through browser console using ajax and it did worked without any issue.

could any any one tell us how to handle this json object and send this to external api using CL_HTTP_CLIENT. Note : JSON STRING is deeply nested .

Thanks in advance..

2
Some people gave you some clues in your question (here but you didn't reply to them, so I'm afraid that people will hesitate to answer here... - Sandra Rossi

2 Answers

0
votes

You can use request catcher service for getting SAP output.
Then check your output has valid json.
Check external api with rest tool like postman or SoapUI. Every developer not track guidliness may be external api has limitations.

0
votes

The issue was with the unicodes in the string. these were not accepted by the external api so removed from the string and sent to api and it did worked.

Thanks for You suggestion.