In http request, the data in body is correct but still receiving status: 400 error

Hi All, I am reading a text file in json form and then using it’s output variable in http request body field. But still receiving below error, even though in Postman it looks correct.
{“message”: “Status: 400\r\nResponse: {"errors":[{"code":400,"message":"Unparsable payload."}],"user_messages":[{"severity":"ERROR","text":"Unparsable payload.","details":{"code":400}}]}”,

Attaching the json file for ref
POD2BodyData.json (3.0 KB)

When reading json from a text file we will read the plain string.

The text file would look like this:

This worked, Thanks !

I have one more query related to this. In between this data I need to use a variable . How do I use that? I used it like in the screenshot attached below

A simple approach could be like defining a placeholder with a specific pattern and then replace it on string base:

#Var1# as a place holder

We would recomend to use chars like { [… as they are too close to the JSON syntax

Another option would be:

  • parse the JSON string
  • manipulate it with proper API methods

I am using the chars and everything you mentioned, but still same error

feedback is unclear. What was done in detail?

image
FirstOfNxtMonth is the variable that I have to use in the json file to add the 1st date of next month in those square brackets. But it is giving me the error stated above. Just wanted to know if the approach I have used in the screenshot above is correct or not? If I am removing the variable and one pair of double quotes the login is working sucessfully.

No, you cannot bypass compilation

We shared with you:

so when using ["#Var1#"] within the textfile you can do

  • read text - strJSON
    strJson = strJson.Replace(“#Var1#”, FirstOfNxtMonth)

Thanks, the solution worked, I was using 2 sets of double quotes instead of single .

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.