I am currently working on establishing a connection to an API. We are using Swagger UI to help us a bit. We are testing the connection in Postman and it works fine, however, when trying to replicate it in UiPath Studio we are experiencing errors like the following below: "
{
“message”: “{"message":"loginModel must not be null","errorCode":0,"traceId":"00-3478f0c125fb77f7ce56121ad97fccb5-03d5f67e396728ef-00","resourceIds":null}”,
“level”: “Trace”,
“logType”: “User”,
“timeStamp”: “13:41:29”,
“jobId”: “4f2c16b0-4859-4e64-9f86-32e05cb3e1d2”,
“robotName”: “stud kbb-attended”,
“machineId”: 162,
“processVersion”: “1.0.0”,
“organizationUnitId”: 99
}
"
We are trying to get a bearer token that is needed to authenticate us for further work.
I am currently looking for the exact CURL command I am supossed to write in HTTP Request activity (when I click import).
I tried doing the following CURL command but it throws the above error:
"
curl -X POST “https://XXX/api/account/authenticate” ^
-H “Content-Type: application/json” ^
-H “Accept: application/json” ^
-d “{ "TenancyName": "XXX", "UsernameOrEmailAddress": "XXX", "Password": "XXX" }”
"
I have linked a screenshot of my Postman, and hopefully it can help you to tell me what to do:
Hi @nmjvk
If you are trying to perform an API request to the Orchestrator tenant the robot is connected to, the easiest way is to use Orchestrator HTTP Request activity
if this still doesn’t work, i would suggest to first try to achieve the same by passing Json body instead of Curl command for the time being and see if that works for you. refer below:
And if your project is on C# language, you can refer below KB from UiPath:
I just trie to eplace my string with yours. I copied exactly this -d “{”“tenancyName”“:”“TENANT_NAME”“,”“usernameOrEmailAddress”“:”“USERNAME”“,”“password”“:”“PASSWORD”“}”
however, I get the error
{"type":"ht tps://tools.ietf.org/html/rfc7231#section-6.5.13","title":"Unsupported Media Type","status":415,"traceId":
We need to use the HTTP request activity for this project. We tried the Orchestrator HTTP Request. We need to be able to feed it a curl command and I am pretty sure you cant do it in the Orchestrator HTTP Request?
I didn’t your point
instead of using postman in UiPath we called http request activity it will act like as postman.
here you need to pass all parameters how you are passing URL and body and parameters same like you need construct in http activity.
from http activity you will get response nothing but output
The absolute best would be if you could give me the CURL command or point out where in my CURL command I did an error, else, you have to tell me which parameters from Postman I need to fill out in my UiPath Studio HTTP Request activity. I already attached all the necessary sceenshots
Pls note that when you use Import command of “HTTP Request” activity to import a CURL command it DOES NOT import the Body argument (at least in my case it did not).
Given the error you posted it looks the body is empty.
I just tried pasting the CURL command in again and check the HTTP Request Wizard. This is what I am seeing. When I do a “Preview” I get the following error code:
{
“message”: “loginModel must not be null”,
“errorCode”: 0,
“traceId”: “00-91c14eda93e73be7b119b8ea7d390609-67d4eb8ac5618b58-00”,
“resourceIds”: null
}
So you might be right in this one. I am still trying to do some digging.
I can hereby confirm that this was all that was needed.
So to summarise. When doing the CURL command the BODY content is not being included “for some weird reason” so you’ll have to manually add it, it my case I needed to manually include the password, username and email as a string.
Thank you for helping @J0ska have a wonderful day forward!
Still believe it would be better to use “Orchestrator HTTP Request” activity as proposed by @dokumentor and do not bother with authentication, just provide specific API endpoint, e.g. “/odata/Users” to get all users.
Using “HTTP Request” you will still need to build the Body (if needed by particular API call) and additionally you need to take care of the authentication, folders etc.
The only scenario when I can imagine the need of using “HTTP Request” is when you want access Orchestrator under other account than current robot.