Switch On Or Off Attended Licenses Through API Calls

How to switch on/off Attended licenses through API?

Using Swagger API:

  1. Go to Swagger or Rest API tool ( with https://cloud.uipath.com/myaccbsjncut/DefaultTenant/orchestrator_/odata/Users(key) and put the user id instead of key) and use the User API call with PUT and click to Try Out.
  1. Afterwards connect in Orchestrator -> go to Manage Access (1) and select the user wanted to modify. Click on the 3 dots (2) and edit user (3).
  1. Open the developer tool by pressing F12 in Chrome browser, in order to monitor the network (6). After, select the Robot setup (1), Enable it (2), insert the domain\user (3), select the license type (4) and click on Update (5)
  1. After clicking update an API call in the developer tool (1) will be sent and check the payload, so click on View Source(2) and copy the entire block in a Notepad ++ or another tool which can format the text into JSON format.
  1. After formatting into JSON format:
    1. To leave the user with the license keep the format of the value "MayHaveRobotSession" set as true.
    2. To disable the license for that user but to keep the user details, next time change the value from true to false for "MayHaveRobotSession".
  2. Take the payload and run it in swagger, this will turn the license on/off.