Unable to Http Request POST API With Attachment

Hi Team,

I am trying to call the POST API by Attaching the two attachments (PDF and JSON). But it is working fine in CMD using CURL but when i am trying it is giving some error.

curl -X POST http://localhost:3001/api/v1/document -H “Content-Type:multipart/form-data” -F “file=@CSE.pdf;type=application/pdf” -F “config=@D:\Parsr\Parsr-0.11.2\Parsr-0.11.2\server\defaultConfig.json;type=application/json”

Can any help me on above command how can we implement it in UiPath with HTTP Request ?

Hi Shashank,

Following is the curl integration in the UIPath, where I have an email gateway (as similar to sms gateway) to trigger the emails with the Curl Command. Note this example uses multipart form data. (As a form-data). I am not sure about http request activity but I hope this might help you.

The request looks like this in Postman:

UIPath Integration:

Install Packages:
Microsft ASP.Net Web Api 2.2 Client Library

Import following from import panel

Use Invoke Code Activity with the following VB.Net code

Dim client As HttpClient = New HttpClient()
client.BaseAddress = New Uri(“Mention your BaseURL”)
client.DefaultRequestHeaders.Accept.Add(New MediaTypeWithQualityHeaderValue(“application/json”))
client.DefaultRequestHeaders.Authorization = New AuthenticationHeaderValue(“Basic”, “your hash code”)
Dim request As MultipartFormDataContent= New MultipartFormDataContent()
request.Add(New StringContent(“John@domain.com”), “from”)
request.Add(New StringContent(“to@domain.com”), “to”)
request.Add(New StringContent(“Mail subject”), “subject”)
request.Add(New StringContent(“Mail Body”), “text”)
request.Add(New StreamContent(File.OpenRead(“C:/Users/Desktop/filename.pdf”)), “attachment”, (New FileInfo(“C:/Users/Desktop/filename.pdf”).Name))
Dim response As HttpResponseMessage = client.PostAsync(“email/2/send”, request).Result
If response.IsSuccessStatusCode Then
Dim responseContent As HttpContent= response.Content
Dim responseString As String = responseContent.ReadAsStringAsync.Result
Console.WriteLine(("failed: " + response.Content.ReadAsStringAsync.Result))
End If


  1. BaseUrl is the text before email/2/send ie. if your api end point is https:/abcde.api.gatway.com/email/2/send then https:/abcde.api.gatway.com/ is your baseURL

  2. The hascode of AuthenticationHeaderValue can be generated by entering your username and password as show in the image below