How to update a Robot through API?

How to update a Robot through API?

Issue Description:

Usually, users utilize the Swagger API endpoints documentation to edit the robot, for example:

PUT for /odata/Robots({key})

Because of that, in some cases, the below error message is encountered:

{

"message": "; robotDto must not be null",

"errorCode": 0,

"resourceIds": null

}


Resolution:

To update the robot/user, follow the below instructions.

Note: Let's assume Robot ID is 109.
The easiest way to find X-UIPATH-OrganizationUnitId open the Orchestrator web page in the browser -> go to Tenant -> right click on the page -> Inspect -> Network -> Click on Users -> scroll down in the page and check the value for x-uipath-organizationunitid (in bellow example is 1)

1.jpg


1. Perform in Postman tool a GET request for this URL: https://ORCHESTRATOR_URL_ADDRESS/odata/Robots(109)?$select=UserId

Authorization:

Bearer Token

Headers:

X-UIPATH-OrganizationUnitId: 1

Content-Type: application/json

2. Copy the UserId value

3. Perform in Postman tool a PUT request for this URL: https://ORCHESTRATOR_URL_ADDRESS/odata/Users(UserId_value_from_step_2)

Authorization:

Bearer Token

Headers:

X-UIPATH-OrganizationUnitId: 1

Body:

raw as JSON

Example of body request:

{

"Id": 4,

"Name": "M*****",

"Surname": "P******",

"UserName": "m*****.p*****",

"DirectoryIdentifier": null,

"Domain": null,

"FullName": "",

"EmailAddress": "m****.p******@mail.com",

"IsEmailConfirmed": false,

"IsActive": true,

"AuthenticationSource": null,

"Password": null,

"LastLoginTime": "2021-12-02T09:56:12Z",

"CreationTime": "2021-11-01T15:08:18Z",

"RolesList": ["Robot"],

"OrganizationUnits": [],

"TenancyName": "Default",

"TenantDisplayName": "Default",

"TenantId": 1,

"Type": "User",

"NotificationSubscription": {

"QueueItems": true,

"Robots": true,

"Jobs": true,

"Tasks": true,

"Schedules": true,

"Queues": true,

"Insights": true,

"CloudRobots": true

},

"MayHaveRobotSession": false,

"MayHaveUnattendedSession": true,

"MayHaveUserSession": true,

"MayHavePersonalWorkspace": false,

"BypassBasicAuthRestriction": false,

"UnattendedRobot": {

"UserName": "UIPATH\\m***.p******",

"CredentialStoreId": 1,

"CredentialType": "Default",

"LimitConcurrentExecution": false,

"ExecutionSettings": {

"TracingLevel": "Information",

"StudioNotifyServer": true,

"LoginToConsole": true

}

},

"IsExternalLicensed": false,

"RestrictToPersonalWorkspace": false

}


Example in Postman:

2.png

Note:

A GET request can be performed in the Postman tool for this URL: https://ORCHESTRATOR_URL_ADDRESS/odata/Users(UserId_value_from_step_2) and already the populated information will be obtained for the robot/user. Afterward, it will be easier to update only the needed details.