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
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:
- Add a Deserialize JSON activity as below
- Add an Assign activity as below
To: Create a new varible (Ctrl + k) named AccessTokenString
Value: "Bearer " + Convert.ToString(AccessToken.GetValue("result"))
Value: "Bearer " + Convert.ToString(AccessToken.GetValue("result"))
- 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
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:
- The rest of the activities are having the same approach as the VB project from above.