Http Request activity to send body using POST method

I have to send three parameters which are in the format of Key/Value pair in the body of POST method in HTTP request activity. Can you help how to do that ?

1 Like

Hi @raviranjan,

You have to import Soap and Rest activities from the packages (Hope you know it :slight_smile:)

Then drag the activity “HTTP Request” into your sequence, it will prompt for the URL and the parameters, you can change the request type as well

Hi Raviranjan,

Using body of POST method you can send it in 2 formats.
JSON or XML.

if JSON
“{”“Key1"”:"“value1"”,"“key2"”:"“value2"”,"“key3"”:"“value3"”}"

Normal JSON will have double quotes or single quotes for key and values but while sending in Body you have to escape the double quotes with another double quotes.(as shown above)

Note: if the value is a interger no need to give double quotes.

Please refer to the following link

1 Like

I understood this part but i need to pass parameters in body as shown in SS. More like a dictionary elements. How do i do that ?ss

I used postman for the same and i am getting the correct output with it.

Can you copy paste the JSON as string instead of screenshot.

Have a look at this

I just tried the same as in the above link, it is working exactly and was a great solution.

Change your body type to application/json and make your body as a string .
Here is the sample body which i tried

“{”“Key”" : ““Value””,"“Key”" : ““Value””,"“Key”" : ““Value””}"

Make sure it is a string and you can directly paste in the body

Just simple make the single (") to double ("") so that it will make the json as string and you don’t need to give spaces for each key value pair.

the json which i am sending is as follows:
“{”“attributes”":{"“Name”":"“West Trail”","“x_axis”":-58.0854173175099,"“y_axis”":6.81321583105365}}"
(Above json is only for the ‘adds’ key from the SS)
But i don’t know how to send the whole key value in single body format.

I tried the following strings:
“{f:json,token:XXXX-XXXX-XXXX-XXXX,adds:{”“attributes”":{"“Name”":"“West Trail”","“type”":"“Hiking Path”","“altitiude”":542.34}}"

And…

“{”“f:”“json”","“token”":"“XXXX-XXXX-XXXX-XXXX”","“adds”":{"“attributes”":{"“Name”":"“West Trail”","“type”":"“Hiking Path”","“altitude”":542.34}}

But none area working. Need help

Try this

“{”“f”":"“json”","“token”":"“xxx-xxxx”","“adds”":{"“attributes”":{"“Name”":"“West Trail”","“type”":"“Hiking Path”","“altitude”":542.34}}}"

Try this…
“{”“f”":"“json”","“token”":"“XXXX-XXXX-XXXX-XXXX”","“adds”":""{"“attributes”":""{"“Name”":"“West Trail”","“type”":"“Hiking Path”","“altitude”":"“542.34"”}""}"

I hope It will work for sure

Nope. :confused:
No luck. One more thing, do i need to pass OAuth2 token in Http Request activity also or just send it along body as we are doing now. Or do we need to pass token in both places.

Have you tried the last one @raviranjan??

Let me know if it is working :slight_smile:

Yup. Just tried it. Its not working :confused:.
Basically, this should upload the given attributes(‘Name’, ‘type’, ‘altitude’, etc.) to a website(Endpoint).
I am attaching the .xaml file. Hope it could help.

Main.xaml (7.0 KB)

Its working and returning 200 success status code. Please find attached xaml.

Main (1).xaml (7.3 KB)

Yeah. But, the problem is its not updating the list in the website which is supposed to be updated after this query. And also, it will return 200 even if the token provided is incorrect. 200 is just an indication that it is successfully hitting the endpoint.

Hi @raviranjan, I am facing the same issue, wanted to know if you were able to resolve the problem, It will be great help for me if you can assist. I am getting the result as 200 with UiPath http request but not able to post the data to the end point, but it is working perfectly with the postman. looking forward for your response

Regards,
pankaj