I need to update API. Previously I am passing value in parameter. How I need to pass in body value? It’s say unsupported media type in title.
-Make sure to check the API documentation to understand the expected format for the request body. It will specify the content type that the API expects.
-Set the Content-Type
header in your HTTP request to match the expected media type. Common types include application/json
for JSON data or application/x-www-form-urlencoded
for form data.
-Construct the request body according to the API documentation. If it’s a JSON request, you might need to serialize your data into a JSON format.
-Use the HTTP Request activity in UiPath to send the request. Set the method (POST, PUT, etc.), URL, headers, and the request body.
-Make sure to handle the API response appropriately. Check the response status and content for any error messages.
Thanks & Cheers
Here’s an example of how you might set up an HTTP request
Endpoint: https://api.example.com/update
Method: POST
Content-Type: application/json
Body: {"key": "value"}
Ensure that the Content-Type
and the structure of the request body align with the API’s requirements.
or
refer to the API documentation to ensure you’re using the correct endpoint and the correct content type for the request
Thanks,
Vinit Mhatre
@Vinit_Mhatre I need to pass four values in body field. It’s working fine in postman but showing error while I try to execute from UiPath (Http request).
{
“abcId”: “1”,
“xyztID”: “1”,
“pqr”: “1”,
“mnp”: “abc”
}
I couldn’t pass this exact value this in body field so, I tried like this "{
““abcId””: "“1"”,
““xyztID””: "“1"”,
““pqr””: ““1"”,
““mnp””: ““abc””
}”
Could you share the screenshot of your workflow?
Show me the properties of HTTP Request Activity
Sending a value in the body parameter of an HTTP request is like putting a note in a letter. You write your letter (HTTP request), create a note (body parameter) with specific info, attach it to the letter, and send it off. For example, if the note is about your favorite color, the body parameter could be something like "color: blue"
. It’s a way of sharing details with a server when making a request.
Change your Body Format to “application/json”
I have tried that as well @Vinit_Mhatre . but it throws this error.
““abcId””: ““1””,
““xyztID””: ““1””,
““pqr””: ““1"”,
““mnp””: ““abc””
}”
this is my value inside body
Could you share me with your actual workflow file? will check and let you know
Well that means your http post request was a succes (or at least, accepted. Check the reponse to be sure) .
The exception occurs on the deserialize JSON activity, so checking the output. Make sure your output is JSON and check its formatting.
@Vinit_Mhatre
Main.xaml (13.5 KB)
Here you go
send me the entire folder of your process
CicNepal_test.zip (3.4 KB)
Write the “cicResponseJson” data into text file and send that text file to me
do you want me to send the log of cicResponseJson? @Vinit_Mhatre