How to send a POST API request in UiPath (step-by-step)

Hi UiPath Community :waving_hand:,

I’m new to working with APIs in UiPath and need some guidance on how to send a POST API request and read the response properly.

I have an API endpoint (URL), a request body (JSON), and I want to send it from UiPath using the HTTP Request activity. I’m a bit confused about where to set the URL, headers, and JSON body, and how to capture the response.

URL : http://192.168.28.11/hmsspeciality19scripts/ASBTStructRest.dll/datasnap/rest/TASBTStruct/savedata

Request Body :
{
“_parameters”: [
{
“savedata”: {
“axpapp”: “hms11hr”,
“s”: “”,
“username”: “webuser”,
“password”: “827ccb0eea8a706c4c34a16891f84e7b”,
“changedrows”: {},
“transid”: “eincd”,
“recordid”: “0”,
“recdata”: [
{
“axp_recid1”: [
{
“rowno”: “001”,
“text”: “0”,
“columns”: {
“emp_no”: “109676”
}
}
]
}
],
“afiles”: “”,
“attachmode”: “”,
“params”:
}
}
]
}

Response :

{“result”:[{“message”:[{“msg”:“Insurance Card Saved”,“recordid”:“1438880003792”}]}]}

@srijo2703

URL goes in endpoint url property.
Headers goes in header collection.
JSON body goes in body.
For response, there is an output parameter, define a variable for that and use it to capture response.

Pls, Need UiPath activity based code

Step 1: Install and Import Dependencies
Step 2: Add HTTP Request Activity

  • HTTP Request → Method: POST
  • URL
  • Headers (Content-Type: application/json)
  • Body (JSON)
  • Output → responseText
  • Deserialize JSON → Input: responseText → Output: jsonResponse
  • Log Message → Message:
"Message: " + jsonResponse("result")(0)("message")(0)("msg").ToString

Message: …
Record ID: …

it shows below mentioned error: 25.10.1+Branch.support-v25.10.Sha.1608af9374be8de1b7ba97b38e72416c51e37a3f.1608af9374be8de1b7ba97b38e72416c51e37a3f

Source: Deserialize the JSON string responseString to a JObject variable named jsonResponse.

Message: Unexpected character encountered while parsing value: <. Path ‘’, line 0, position 0.

Exception Type: Newtonsoft.Json.JsonReaderException

in SFTP_.xaml
at DeserializeJson`1 “Deserialize the JSON string responseString to a JObject variable named jsonResponse.”
at Sequence “Sequence”
at Flowchart “SFTP_”
at SFTP_ “SFTP_”

Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path ‘’, line 0, position 0.
at Newtonsoft.Json.JsonTextReader.ParseValue()
at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at UiPath.Web.Activities.DeserializeJson`1.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

@srijo2703

Is the response coming in json?

First try to print the response body to check the value

Cheers