What is API?
API is the acronym for Application Programming Interface, which is a software intermediary that allows two applications to talk to each other.
An example of an API?
When you install and use a mobile app, the mobile app connects to the Internet and sends data to a server. The server then retrieves that data, interprets it, performs the necessary actions and sends it back to your phone. The application then interprets that data and presents you with the information you wanted in a readable way. This is what an API is – all of this happens via API.
To understand it better, Let’s take the real-time case:
When you visit the hotel to book a room, the receptionist will check the availability and present you with the required details like the cost of the room, room type, the number of days the room available to book, etc… as requested. Here receptionist will act as the intermediary as API, this is what an API will do.
What is the use of Orchestrator API?
APIs here are used to interact with the Orchestrator from any third-party application, even from the UiPath Studio/Robot.
Basic functionality which can be achieved through APIs are
- Start/Stop the Job
- Check the status of the Robots
- Create/Modify the Assets
- Create a queue and push the items into the Queue
- Check the Status of the Jobs
- Get the Environment, Process, Robots, Queue, Jobs details and So on…
What will you learn by the end of this Article?
You will able to
- Authenticate the API
- Get all the Robots data from Orchestrator
- Get the state of the Robot
- Get the all the Process from Orchestrator
- Get the all the Jobs from Orchestrator
- Get the all the Releases from Orchestrator
- Start the Job from Orchestrator
- Stop the Job from Orchestrator
- Get all the Assets from Orchestrator
- Update the Asset
- Create the Queue
- Add item to the Queue
Where we need the Orchestrator APIs?
To communicate with the orchestrator and to use its functionality from the third-party application, we need the Orchestrator API’s which helps in creating communication bridge both the Applications.
Note: We have used postman to demonstrate the article
Authenticate:
Request (Post Call)
Response (200 OK)
“result” parameter value will be used for the authorization (Bearer Type) in all the API calls of Orchestrator.
NOTE: By default, the bearer token expires after 60 minutes. You can change the expiry time, by modifying the value of the Auth.Cookie.Expire parameter, in the Web.config file.
Get all the Robots data from Orchestrator
Request (Get Call)
Response (200 OK)
{
“@odata.context”: ” {{url}}/odata/$metadata#Robots”,
“@odata.count”: 1,
“value”: [
{
“LicenseKey”: null,
“MachineName”: “string”,
“MachineId”: 199990,
“Name”: ” string “,
“Username”: ” string “,
“ExternalName”: null,
“Description”: null,
“Version”: “19.10.0.484”,
“Type”: “Unattended”,
“HostingType”: “Standard”,
“ProvisionType”: “Manual”,
“Password”: null,
“CredentialStoreId”: null,
“UserId”: null,
“CredentialType”: null,
“RobotEnvironments”: ” string “,
“IsExternalLicensed”: false,
“Id”: 215728,
“ExecutionSettings”: null
}
]
}
NOTE: @odata.count will give the total number of robots available in the orchestrator.
Get the state of the Robot
Request (Get Call)
Response (200 OK)
{
“@odata.context”: ” {{url}}/odata/$metadata#Sessions(State)”,
“@odata.count”: 1,
“value”: [
{
“State”: Available
}
]
}
NOTE: Robot Id can get from the Get all robots API call. Possible State of the Robots is Available, Busy, Disconnected, Unresponsive.
Get the all the Process from Orchestrator
Request (Get Call)
Response (200 OK)
{
“@odata.context”: ” {{url}}/odata/$metadata#Processes”,
“@odata.count”: 4,
“value”: [
{
“IsActive”: false,
“Title”: null,
“Version”: “1.0.7144.12881”,
“Key”: “PackageName:1.0.7144.12881”,
“Description”: “string”,
“Published”: “2019-10-13T08:15:53.403Z”,
“IsLatestVersion”: true,
“OldVersion”: null,
“ReleaseNotes”: null,
“Authors”: “string”,
“Id”: “string”,
“Arguments”: {
“Input”: null,
“Output”: null
}
},
{
“IsActive”: false,
“Title”: null,
“Version”: “1.0.1”,
“Key”: “string”,
“Description”: “Blank Process”,
“Published”: “2019-11-08T15:57:31.8Z”,
“IsLatestVersion”: true,
“OldVersion”: null,
“ReleaseNotes”: null,
“Authors”: “string”,
“Id”: “string”,
“Arguments”: {
“Input”: null,
“Output”: null
}
},
{
“IsActive”: false,
“Title”: null,
“Version”: “1.0.7223.18293”,
“Key”: “PackageName:1.0.7223.18293”,
“Description”: “string”,
“Published”: “2019-10-12T15:19:53.95Z”,
“IsLatestVersion”: true,
“OldVersion”: null,
“ReleaseNotes”: null,
“Authors”: “string”,
“Id”: “string”,
“Arguments”: {
“Input”: null,
“Output”: null
}
},
{
“IsActive”: false,
“Title”: null,
“Version”: “1.0.1”,
“Key”: “Generate_Yearly_Report:1.0.1”,
“Description”: “Generate Yearly Report”,
“Published”: “2019-06-06T09:19:12.247Z”,
“IsLatestVersion”: true,
“OldVersion”: null,
“ReleaseNotes”: null,
“Authors”: “Package”,
“Id”: “Generate_Yearly_Report”,
“Arguments”: {
“Input”: null,
“Output”: null
}
}
]
}
NOTE: @odata.count will give the total number of Environments available in the orchestrator.
Get the all the Jobs from Orchestrator
Request (Get Call)
Response (200 OK)
{
“@odata.context”: ” {{url}}/odata/$metadata#Jobs”,
“@odata.count”: 3,
“value”: [
{
“Key”: “string”,
“StartTime”: “2019-09-27T16:25:52.053Z”,
“EndTime”: “2019-09-27T16:25:52.053Z”,
“State”: “Faulted”,
“Source”: “Manual”,
“SourceType”: “Manual”,
“BatchExecutionKey”: “string”,
“Info”: “string”,
“CreationTime”: “2019-09-27T16:25:51.343Z”,
“StartingScheduleId”: null,
“ReleaseName”: “string”,
“Type”: “Unattended”,
“InputArguments”: null,
“OutputArguments”: null,
“HostMachineName”: “string”,
“HasMediaRecorded”: false,
“PersistenceId”: null,
“ResumeVersion”: null,
“StopStrategy”: null,
“ReleaseVersionId”: null,
“Id”: 14681107
},
{
“Key”: “string”,
“StartTime”: “2019-09-27T16:27:22.527Z”,
“EndTime”: “2019-09-27T16:27:48.76Z”,
“State”: “Successful”,
“Source”: “Manual”,
“SourceType”: “Manual”,
“BatchExecutionKey”: “string”,
“Info”: “Job completed”,
“CreationTime”: “2019-09-27T16:27:18.55Z”,
“StartingScheduleId”: null,
“ReleaseName”: “string”,
“Type”: “Unattended”,
“InputArguments”: null,
“OutputArguments”: “{}”,
“HostMachineName”: “string”,
“HasMediaRecorded”: false,
“PersistenceId”: null,
“ResumeVersion”: null,
“StopStrategy”: null,
“ReleaseVersionId”: null,
“Id”: 14681154
},
{
“Key”: “string”,
“StartTime”: “2019-11-11T15:28:52.6Z”,
“EndTime”: “2019-11-11T15:29:21.497Z”,
“State”: “Successful”,
“Source”: “Manual”,
“SourceType”: “Manual”,
“BatchExecutionKey”: “string”,
“Info”: “Job completed”,
“CreationTime”: “2019-11-11T15:28:51.443Z”,
“StartingScheduleId”: null,
“ReleaseName”: “string”,
“Type”: “Unattended”,
“InputArguments”: null,
“OutputArguments”: “{}”,
“HostMachineName”: “string”,
“HasMediaRecorded”: false,
“PersistenceId”: null,
“ResumeVersion”: null,
“StopStrategy”: null,
“ReleaseVersionId”: 492076,
“Id”: 16757097
}
]
}
NOTE: @odata.count will give the total number of jobs available in the orchestrator Jobs tab.
Get the all the releases from Orchestrator
Request (Get Call)
Response (200 OK)
{
“@odata.context”: ” {{url}}/odata/$metadata#Releases”,
“@odata.count”: 1,
“value”: [
{
“Key”: “07be5eca-a159-4faf-acc2-4fd5029b6326”,
“ProcessKey”: “Generate_Yearly_Report”,
“ProcessVersion”: “1.0.1”,
“IsLatestVersion”: false,
“IsProcessDeleted”: false,
“Description”: “”,
“Name”: “Generate_Yearly_Report_env1”,
“EnvironmentId”: 96731,
“EnvironmentName”: “env1”,
“InputArguments”: null,
“Id”: 119460,
“Arguments”: {
“Input”: null,
“Output”: null
},
“ProcessSettings”: null
}
]
}
NOTE: @odata.count will give the total number of Releases available in the orchestrator Jobs tab.
Start the Job from Orchestrator
Request (Post Call)
Response (201 Created)
NOTE: ReleaseKey required to do this post call can get by using the Get Call of Releases and Robot Ids can get using the Get call of Robots.
The first Job will be Triggered by the pending status.
Stop the Job from Orchestrator
Request (Post Call)
Response (200)
NOTE: JobIds required to do this post call can get by using the Get Call of Jobs and Only Running state jobs can be stopped.
Get all the Assets from Orchestrator
Request (Get Call)
Response (200 Ok)
{
“@odata.context”: “{{url}}/odata/$metadata#Assets”,
“@odata.count”: 2,
“value”: [
{
“Name”: “string”,
“CanBeDeleted”: true,
“ValueScope”: “Global”,
“ValueType”: “Credential”,
“Value”: “username: “,
“StringValue”: “”,
“BoolValue”: false,
“IntValue”: 0,
“CredentialUsername”: “”,
“CredentialPassword”: “”,
“ExternalName”: null,
“CredentialStoreId”: 96902,
“HasDefaultValue”: true,
“Description”: “acme credentials”,
“Id”: 173648,
“KeyValueList”: []
},
{
“Name”: “string”,
“CanBeDeleted”: true,
“ValueScope”: “Global”,
“ValueType”: “Credential”,
“Value”: “username: “,
“StringValue”: “”,
“BoolValue”: false,
“IntValue”: 0,
“CredentialUsername”: “”,
“CredentialPassword”: “”,
“ExternalName”: null,
“CredentialStoreId”: 96902,
“HasDefaultValue”: true,
“Description”: null,
“Id”: 130220,
“KeyValueList”: []
}
]
}
NOTE: @odata.count will give the total number of Assets available in the orchestrator Jobs tab.
Update the Asset
Request (Put-Call)
Sample Body:
{
“Name”: “string”,
“CanBeDeleted”: true,
“ValueScope”: “Global”,
“ValueType”: “DBConnectionString”,
“Value”: “string”,
“StringValue”: “string”,
“BoolValue”: true,
“IntValue”: 0,
“CredentialUsername”: “string”,
“CredentialPassword”: “string”,
“ExternalName”: “string”,
“CredentialStoreId”: 0,
“KeyValueList”: [
{
“Key”: “string”,
“Value”: “string”
}
],
“HasDefaultValue”: true,
“Description”: “string”,
“RobotValues”: [
{
“RobotId”: 0,
“RobotName”: “string”,
“KeyTrail”: “string”,
“ValueType”: “DBConnectionString”,
“StringValue”: “string”,
“BoolValue”: true,
“IntValue”: 0,
“Value”: “string”,
“CredentialUsername”: “string”,
“CredentialPassword”: “string”,
“ExternalName”: “string”,
“CredentialStoreId”: 0,
“KeyValueList”: [
{
“Key”: “string”,
“Value”: “string”
}
],
“Id”: 0
}
],
“Id”: 0
}
Response (200 Successfully Updates)
NOTE: Id required to do this put-call can get by using the Get Call of Assets.
Create the Queue
Request (Post Call)
Response (201 Created)
Add item to the Queue
Request (Post Call)
Response (201 Created)
******************************************END**************************************
Hope you have enjoyed the article….
What is the sample of string looking like in the key value pair “Value” : “string” ???