Http Request Body how to format body and pass request

I’m trying to understand the Http request activity. The issue I’m having is with the request. When I run my request through postman it works but I’m not sure how to add the body in the http activity. In Poastman the body is in multi line format and Uipath it has to be formatted differently. How do do i write the body/request in the correct format and how would i pass the request in the http activity? Would i create a variable as a request and add that variable in the body of the properties section? I’m getting a status code of 200 I just need to figure out how to format the request in the correct way. Help is much appreciated

Hi,

I’m guessing you’re talking about the json string. I think the property requires an expression which normally should be in one line, but you can use “_” to put strings on multiple lines. You might check this tool out though to convert a multi-line json string to a single line: Online Multiline to Singleline Converter - Text/JSON/XML

If you need further help, I would suggest posting some screenshots or examples. Also, if you are looking to perform http request with Orchestrator, use the Orchestrator HTTP activity cause it’s easier. :wink:

Regards

Clayton,
Thanks for the response, I used the single line converter like you suggested, thank you for that it will be a good tool moving forward. I Converted the multi line code and copy and pasted into the body property of the http activity and I’m getting the attached errors. I posted the sample multi line code im trying to use at the bottom of this. Let me know what you think.

Thanks

{

“quotebackId”: “Plan P Branded”,

“subCustomerId”: “ISO1”,

“permissibleUsage”: “IN”,

“requestType”: “P”,

“request”: [

{

“requestId”: “1”,

“licensePlate”: “7733XP”,

“licenseState”: “FL”

}

],

“requestPlate”: “Y”,

“requestBranded”: “N”

}

When I run it without adding the code in the body I’m getting a 200 status code but once I add the code into the body i get a status code of 400.

If you’re getting the validation error as shown in the screenshot, you just need to place your quotations correctly so they are embedded in the string.

"{ ""quotebackId"": ""Plan P Branded"", ""subCustomerId"": ""ISO1"", ""permissibleUsage"": ""IN"", ""requestType"": ""P"", ""request"": [ { ""requestId"": ""1"", ""licensePlate"": ""7733XP"", ""licenseState"": ""FL"" } ], ""requestPlate"": ""Y"", ""requestBranded"": ""N"" }"

so it’s all in the color orange/red to indicate it’s a string.

Hope that fixes your validation errors, if you still get them.

I’m not sure on the status codes. 400 indicates a bad request, so could be an issue with your EndPoint. But, like I said, I am unsure.

I fixed the code and the errors are gone but I’m still not getting anything in return. When i run it without the body i get a status code of 200 but when i add the request i get a status code of 400. the end point seems to be working. I’m not sure either

You might use the Deserialize activity on your json string to ensure it’s in the correct format. It would at least rule out a syntax problem.

Clayton,
I got it figured out, I used the Deserialize activity and changed the body format to application/JSON and i got the same response as I do in postman. thanks for the help.

1 Like

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