Unable to send payload for HTTP post request

I am trying to make a post request and send the following payload in the body. The payload works fine in postman, but it throws an error in Uipath.

Payload used in postman :
{“searchFilterMap”: {“issueDate”: {“fieldName”: “issueDate”,“filterOperator”: “gt”,“filterValue”: “2018-10-04”,“andOrOperator”: “AND”}},“paging”: {“page”: 1,“pageSize”: 100},“sortList”: [{“property”: “issueDate”,“direction”: “DESC”}],“resultList”: }

Payload used in Uipath after formatting:
“{”“searchFilterMap”":"{“issueDate”":""{"“fieldName”": ““issueDate””,"“filterOperator”": ““gt””,"“filterValue”": ““2018-10-04"”,”“andOrOperator”": ““AND””}"},“paging”: “{”“page”": ““1"”,”“pageSize”": 100}",“sortList”: “[”"{"“Property”":"“issueDate”","“direction”":"“DESC”"}""]",“resultList”": “”""}"

Thank you !!

What is the error? It would be better to read the JSON from a text file instead of storing it in UiPath variable.

Buddy this link can surely help you to resolve this

Cheers

Hi, help me pleases, I can not use variables in body json.
https://youtu.be/R5jPPzRc4qI

It is always difficult to maintain a string variable with JSON, since you need to escape all double quotes. My recommendation would be to keep the JSON template in a text file with place holders for variables. Read the text and replace the place holders with correct variable values using UiPath, and then use it as the JSON string for the api calls.

2 Likes

Thanks, it worked.

Like others I don’t recommend manually compiling your JSON in that way. loading it from another source or storing it as an object and converting it to JSON would be more manageable.

I did watch half the video and in the context you are missing your quotes when using your variable.

Good
image
"{""title"":""Prueba"", ""body"":""also es algo""}"

Bad
image
"{""title"":""Prueba"", ""body"":"+Texto+"}"

Unless the Texto variable itself contains double quotes in the string, then you need to add double quotes in your JSON template to encase it.

It worked. Solved. you have to remove double quotes and enter in the file.

Can you please send the sample project. Thanks.

Can you please send the sample project. I have the same issue. Thanks