Updating Robot credentials using API

Studio/Robot version: Studio 2019.4.4

When I call the API I go through the authentication, as seen in the below screenshot. Here all goes well, and I can retrieve the data I want from the robot with a GET. I make use of the Orchestrator HTTP request activity.
I authenticate myself with an HTTP Basic Authentication, and a response from odata/Robots(ID) with a GET request it all works as intended.
If I do the same steps, but instead use any other request like a DELETE, which doesn’t require any other information than an ID in the path. I get the following message:
billede

I would argue that I was indeed authorized, due to the above response from the Authentication. I do make use of an administrative user which can go into the webpage and remove the robots manually when authenticating myself up against the API.

Given this guide: https://orchestrator.uipath.com/v2017.1/reference#robots_putbyid-1 I should just be able to update the login information as I wished.

Does anyone know what might cause this error, or if it is something to do with the API itself?

Best regards

UPDATE:

So after some hairpulling and endless testing, I finally got it to work.
I believe that there is something wrong with the Orchestrator HTTP Request activity when it comes to accessing the odata/Robots. But if you are only interested in updating the Assets it works just fine.

If you, like me, want to update the credential on the robot, you need to make use of the HTTP Request activity, which is from the UiPath.Web.Activities.HttpClient. Here you need to specify your RootEndPoint, like:
orchestratorUrl/odata/Robots(Id) (Note: ID is to get a specific robot)

If you then want to update it use a PUT and a JSON Payload, with the following content set:

  • LicenseKey
  • MachineName
  • Name
  • Username
  • Type
  • Password
  • Id

It doesn’t say anything in the documentation about needing to specify the same ID in the JSON payload and URL in order to make it work, but I have experienced through trial and error that you do indeed need to do this.

FYI: By using HTTP Request instead of Orchestrator HTTP Request, you are responsible to keep track of the RootEndPoint (being the URL for the orchestrator itself) if you wish to use your application across multiple Orchestrators.

You still need to authenticate yourself before trying to communicate with the API, look in the documentation, to see how.

1 Like

Hi @swangL

Could you clarify the documentation issue? (I assume you are referring to swagger definitions?)

It does say that the ID is needed in the URL here:


image

As to the id in the definition itself, the model states it is optional. Is this the discrepancy you have on mind?

Of cause, so the screenshot I have taken, and as you have, says that the ID is required in as a paramter in the URL, which makes perfect sense.

This is not the issue though. The issue was that when I tried to use the Orchestrator HTTP Request activity it kept giving me the message that I was not authorized, even though I was, given the screenshot from the original post.

But when I then went over to use the HTTP Request activity, I set all the required parameters as given from the documentation, and got the return message: “Robot doesn’t exist”. This changed when I sat the parameter ID in both the body parameters/JSON payload and the URL as the same (in my case I tried to update robot with ID 23). When I did this it worked using the HTTP Request activity, but still failed using the Orchestrator HTTP Request activity with the same error message.

So what I take from this is two things:

  1. The activity Orchestrator HTTP Request doesn’t work with all API operations. For example, it works fine with all methods given the path odata/Assets but doesn’t work with all the Methods on odata/Robots.

  2. In order to make the PUT method work for HTTP Request activity, you do indeed need to specify the ID both in the URL (as said in the documentation), but also in the body parameters/JSON payload, which is said not to be required given the documentation.

I do not think that there is anything wrong with the documentation, but rather the activities that are used trying to communicate with the API, given that you need to specify the ID in the body parameters (which makes it required), in order to be able to find the robot, you wish to update, when using the HTTP Request.

1 Like