How to use API through http request activity

Hi,

I am trying to get this free API to work. Documentation can be found here: API | MotorAPI

I have read the guide from UiPath Documentation Portal regarding http requests, but I cannot get how this is done in this case.

Can somebody please guide me how to get a response from the API or send a dummy workflow?

API key is wa3lybrygsxb5scdbjgieu5snisq746j

Thanks.

Hi, did you find any solution?

Hello Steffen,
Here you have a playlist with 10 videos all working with HTTP Request working with Salesforce, ServiceNow, and Jira. So you can see exactly how I work with parameters all videos have Chapters to be able to find very fast what you want.

Thanks,
Cristian Negulescu

1 Like

Hi Cristian, I have a problem with http request in UiPath Studio and I was wondering if you could help me.

Hello Denisa,
Give me Photos with the postman where is working then an error from UiPath Studio and maybe the Full Curl command. After I have full details I will try to look at this.
Thanks,
Cristian Negulescu

I can’t provide you an image from postman because it contains confidential data.
I created a post request in Studio and from that activity I receive a key and a value which I use in a get request as a header and the value changes after each runtime. I tried to put these values in two variables after the post request so they can be modified after each runtime but when I tried to use them in the get request I get an error .

@Denisa_Zah your Body is JSON please BUILD a real JSON like in this movie don’t lose your time with the string

I don’t think I was clear enough. My bad…
So I am making a post request where I provide an endpoint and a body where I have a username and a password. From that post activity I get as an output a header from where I extract a key and a value witch I have to use later for the get method. My key is static but my value is changing every 12 hours. In the previous picture you can see I tried to put the key and the value in two variables so they can change when needed. When i try to do the get request and put my variables in the hearted section is not working and I don’t understand why it won’t accept a variable. Everything is working as it should except the get request.

Hello Denisa,
Sorry but the first time I don’t understand so well, Now I hope I understand better.
So I never the OutPut Headers from HTTP Request, so I don’t have experience with this. From what I see in the picture you need to save your variables as a string item.Key.ToString and item.Value.ToString.
If still is not working and in the postman everything is OK. You need to go with another approach like me on this movie:

Basically, you write your HTTP Request in VB.NET or C# and you use the invoke code activity, and you will use IN and OUT arguments to transfer your data to UiPath Workflow.
Here is an example of code:

Dim client2 As HttpClient = New HttpClient()
Dim filebytes As Byte() = File.ReadAllBytes("c:\\yourfile.docx")
Dim urilink As Uri = New Uri("https://yoururl")
Dim request2 As ByteArrayContent = New ByteArrayContent(filebytes)
request2.Headers.ContentType = New MediaTypeHeaderValue("application/octet-stream")
Dim response2 As HttpResponseMessage = client2.PostAsync(urilink, request2).Result
Dim stat As String = response2.StatusCode.ToString

Thanks,
Cristian Negulescu

1 Like

Why are you not using the HttpRequest activity? Are there some known bugs, like it not always sending the headers?