UI Path Orchestrator Intergation through API complete guide for community version 2019

Step By Step Guide in order to trigger the UI Path Bot through API

Getting Token to Use in Your API Calls
Generating Code Challenge and Code Verifier

  1. In a web browser window, go to Node.js Online Compiler & Interpreter - Replit.
  2. Paste the following code in the index.js file:

function base64URLEncode(str) {
return str.toString(‘base64’)
.replace(/+/g, ‘-’)
.replace(///g, ‘_’)
.replace(/=/g, ‘’);
}

function sha256(buffer) {
return crypto.createHash(‘sha256’).update(buffer).digest();
}

console.log(“Generating challenge and Verifier”);
var cryptoResult = crypto.randomBytes(32);
var verifier = base64URLEncode(cryptoResult);
var challenge = base64URLEncode(sha256(verifier));
console.log("Code challenge: " + challenge)
console.log("Code verifier: " + verifier);

  1. Click Run on the top of the page. The output should look like this:
    Generating challenge and Verifier
    Code challenge: 6FmSWYSNC1I-7fC6oTIEGz-FirleVDkAVjxkkbYNzc4
    Code verifier: IwqVfyjRULvl5Yz9S8InPTVqZTlfJn5MysOOOZrXDKs

  2. Save the codes.

Getting Authorization Code

  1. Copy the following URL in a text editor, such as Notepad:
    UiPath[Code Challenge]&code_challenge_method=S256&scope=openid+profile+offline_access+email &audience=https%3A%2F%2Forchestrator.cloud.uipath.com&client_id=5v7PmPJL6FOGu6RB8I1Y4adLBhIwovQN&redirect_uri=https%3A%2F%2Faccount.uipath.com%2Fmobile
  2. Replace [Code challenge] with your Code challenge generated in step 3 of the previous section.
  3. Copy the updated URL.
  4. Open a web browser window.
  5. Paste the updated URL into the address bar, and press Enter. You are redirected to a UiPath Login page.
  6. Login using your credentials.
  7. The browser’s Text window shows OK, with the URL in the following format:
    https://account.uipath.com/mobile?code=[Authorization code]&state=47441df4d0f0a89da08d43b6dfdc4be2
  8. Copy this [Authorization code] for later use.

Getting Refresh Token

  1. In any API testing tool, perform a POST request to the https://account.uipath.com/oauth/token URL. In the body of the request, replace [Authorization code] and [Code verifier] with the values received in the two procedures above. The request and response should look as in the following example

POST https://account.uipath.com/oauth/token

Request
Content-Type: application/json
{
“grant_type”: “authorization_code”,
“code”: “[Authorization code]”,
“redirect_uri”: “https://account.uipath.com/mobile”,
“code_verifier”: “[Code verifier]”,
“client_id”: “5v7PmPJL6FOGu6RB8I1Y4adLBhIwovQN”
}

Response
Content-Type: application/json
{
“access_token”: “[access token]”,
“refresh_token”: “[refresh token]”,
“id_token”: “[id token]”,
“scope”: “openid profile email offline_access”,
“expires_in”: 86400,
“token_type”: “Bearer”
}

  1. Copy the [refresh_token] from the body of the response for later use.

Generating Access Token and ID Token Using the Refresh Token

Important!
The [access_token] required for making API calls is valid for 24 hours. You have to regenerate [access_token] and [id_token] using your [refresh_token], otherwise you receive 401 status code.

  1. In any API testing tool, perform a POST request to the https://account.uipath.com/oauth/token URL. In the body of the request, replace [refresh_token] with the refresh_token value received in the procedure above. The request and response should look as in the following example:

POST https://account.uipath.com/oauth/token

Request
Content-Type: application/json
{
“grant_type”: “refresh_token”,
“client_id”: “5v7PmPJL6FOGu6RB8I1Y4adLBhIwovQN”,
“refresh_token”: “[refresh token]”
}

Response
Content-Type: application/json
{
“access_token”: “[access token]”,
“id_token”: “[id token]”,
“scope”: “openid profile email offline_access”,
“expires_in”: 86400,
“token_type”: “Bearer”
}

  1. Copy [access_token] and [id_token] for later use.

Discovering UiPath Account and Service Instance Identifiers

Getting Account Logical Name

  1. In any API testing tool, perform a GET request to the UiPath URL. You need to use Authorization header with your Bearer Token, pasting the [id_token]value received in the procedure above. The request and response should look as in the following example:

GET UiPath

Request
Authorization: Bearer [id_token]

Response
Content-Type: application/json
{
“userEmail”: “[user_email]”,
“accounts”: [
{
“accountName”: “[account_name]”,
“accountLogicalName”: “[account_logical_name]”
}
]
}

  1. Copy [account_logical_name] for later use.

Getting Service Instance Logical Name

  1. Copy the following URL into API testing tool, to perform a GET request: UiPath
  2. Replace the [account_logical_name] with the value obtained in the procedure above.
  3. You need to use Authorization header with your Bearer Token, pasting the [id_token] value received in the procedure above.
    The request and response should look as in the following example:

GET UiPath

Request
Authorization: Bearer [id_token]

Response
Content-Type: application/json
[
{
“serviceInstanceName”: “[service_instance_name]”,
“serviceInstanceLogicalName”: “[service_instance_logical_name]”,
“serviceType”: “ORCHESTRATOR”,
“serviceUrl”: “[service_url]”
}
]

  1. Copy [service_instance_logical_name] for later use.

Important!
All Orchestrator API calls subsequent to the initial authorization have to contain the following headers:

Authorization: Bearer [access_token]
X-UIPATH-TenantName: [service_instance_logical_name]

Below api is used to get all the process available inyour community edition:

Get
https://platform.uipath.com/{Account_logical_name}/{Service_instance_logical_name}/odata/Releases

below headers are mandatory in order to call any API.
Authorization: Bearer [access_token]
Content-Type: application/json
X-UIPATH-TenantName: [service_instance_logical_name]

Response:
{
@odata.context”: “https://platform.uipath.com/isbglobal/ISBglobalDe85sa223806/odata/$metadata#Releases”,
@odata.count”: 1,
“value”: [
{
“Key”: “xxxx-x-xxx-xx-xxxxx”,
“ProcessKey”: “ProcessKey”,
“ProcessVersion”: “1.0.2”,
“IsLatestVersion”: false,
“IsProcessDeleted”: false,
“Description”: “”,
“Name”: “EnvironmentName”,
“EnvironmentId”: 44914,
“EnvironmentName”: “EnvironmentName”,
“InputArguments”: null,
“Id”: 46314,
“Arguments”: {
“Input”: null,
“Output”: null
},
“ProcessSettings”: null
}
]
}

final API in order to trigger your Bot through API

Post
https://platform.uipath.com/{Account_logical_name}/{Service_instance_logical_name}/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs

Note: you need to pass the key of process you receveid in previous API, that it you are done.
Request:
{
“startInfo”: {
“ReleaseKey”: “[release key]”,
“Strategy”: “All”,
“RobotIds”: ,
“NoOfRobots”: 0
}
}

9 Likes

@Manish_Jawla this looks fantastic thank you for the contribution!

2 Likes

@Manish_Jawla
Interesting .i will bookmark it and shared it once needed

cheers

2 Likes

Thank You :slight_smile:

Please refer the below url for updated Information:
It become very simple now:

https://docs.uipath.com/orchestrator/reference#consuming-cloud-api

Regards,
Manish Jawla

1 Like

How can you get the new refresh token every 24 hours?

Hi bogdan,
You don’t need new refresh token in every 24 hours, it’s Access Token & id_token which will expire in 24 hours, on every api call you can first call the below api and pass the latest access_token or id_token.


Please read the important section carefully.
Please let me know if it helps.
Cheers!

Hi @Manish_Jawla,

I don’t understand where I am doing wrong. Can you please help me ?
I am getting the output in html format for releasekey and robots. What should I do? Please help. Since 2 days I am trying to get the proper output :frowning:
Thanks in advance.

Regards,
Hemal

Hi Hema,
Can you please elaborate what actually you want to achieve?
what steps you have followed?
what you have received as output?
What i understood is you need release key for triggering the process.?
which api you are using?

Regards,
Manish Jawla

Hey @Manish_Jawla,

I have done it. Thanks :slight_smile:

Regards,
Hemal

Hi Manish_Jawla

Wonderful information!!!

I have created a video series on how we can use Orchestrator API and access UiPath Orchestrator components.

Link Orchestrator API

Your feedback will be highly appreciated.

Thanks,
Priyanka