0

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..

1
  • 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... Aug 10, 2020 at 13:11

2 Answers 2

0

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.

2
  • We did tried out by downloading the JSON object created in abap and used its postman as well. It was working perfectly in postman... Aug 10, 2020 at 14:35
  • So, there is problem exists after json creation. please check your request with request checker.
    – mkysoft
    Aug 10, 2020 at 14:41
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.