How To Retrieve The Bearer Token From On-Premise Orchestrator Using The HTTP Request Activity?

How to retrieve the bearer token from On-Premise Orchestrator using the HTTP Request Activity?

How to retrieve the bearer token from On-Premise Orchestrator using the HTTP Request Activity?

For a VB project use the below details in the workflow:

  • In project add UiPath.WebAPI.Activities[1.11.1] dependency

In Workflow add an HTTP Request activity with these details:
Timeout (milliseconds): 20000
AcceptFormat: ANY
RequestMethod: POST
Request URL: "https://ORCHESTRATOR_HOSTNAME/api/Account/Authenticate"
Body: "{""tenancyName"": ""TENANT_NAME"",""usernameOrEmailAddress"": ""USERNAME"",""password"": ""PASSWORD""}"
Body Format: application/json
Response content: Create a new varible (Ctrl + k) named ResponseResults

Example:
image.png
  • Add a Deserialize JSON activity as below
image.png
  • Add an Assign activity as below
To: Create a new varible (Ctrl + k) named AccessTokenString
Value: "Bearer " + Convert.ToString(AccessToken.GetValue("result"))
image.png
  • Now the AccessTokenString variable will hold the Bearer access token to continue Orchestrator API requests.

====

For a C# project use the below details in the workflow:
  • In project add UiPath.WebAPI.Activities[1.11.1] dependency

In Workflow add an HTTP Request activity with these details:
Timeout (milliseconds): 20000
AcceptFormat: ANY
RequestMethod: POST
Request URL: "https://ORCHESTRATOR_HOSTNAME/api/Account/Authenticate"
Body: @"{
" + "\n" +
@"""tenancyName"":""TENANT_NAME"",
" + "\n" +
@"""usernameOrEmailAddress"":""USERNAME"",
" + "\n" +
@"""password"":""PASSWORD""
" + "\n" +
@"}";
Body Format: application/json
Response content: Create a new varible (Ctrl + k) named ResponseResults

Example:
image.png
  • The rest of the activities are having the same approach as the VB project from above.