Curl Implementation

Hi All,
I am stuck,I want to run curl command from inside uipath but not able to .
http request are also not working.

Advice
Regards
rahul

Hi Rahul,

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)

The request looks like this in Postman:

UIPath Integration:

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

Import following from import panel
System
System.Net.Http
System.Net.Http.Header

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.Clear()
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(responseString)
Else
Console.WriteLine(("failed: " + response.Content.ReadAsStringAsync.Result))
End If

Note:

  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