autoit / Orchestrator / Jobs - Start job
Back to Collection Items
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oHttp = ObjCreate("Chilkat.Http")
Local $bSuccess
; Use this online tool to generate code from sample JSON: Generate Code to Create JSON
; The following JSON is sent in the request body.
; {
; "startInfo": {
; "ReleaseKey": "f689e02d-f968-494f-8b37-409a1bd85534",
; "Strategy": "Specific",
; "RobotIds": [
; 9826
; ],
; "JobsCount": 0,
; "Source": "Manual"
; }
; }
$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.UpdateString("startInfo.ReleaseKey","f689e02d-f968-494f-8b37-409a1bd85534")
$oJson.UpdateString("startInfo.Strategy","Specific")
$oJson.UpdateInt("startInfo.RobotIds[0]",9826)
$oJson.UpdateInt("startInfo.JobsCount",0)
$oJson.UpdateString("startInfo.Source","Manual")
$oHttp.SetRequestHeader "Content-Type","application/json"
; Adds the "Authorization: Bearer <access_token>" header.
$oHttp.AuthToken = "<access_token>"
$oHttp.SetRequestHeader "X-UIPATH-OrganizationUnitId","{{folderId}}"
$oHttp.SetRequestHeader "X-UIPATH-TenantName","{{tenantName}}"
Local $oResp = $oHttp.PostJson3("https://domain.com/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs","application/json",$oJson)
If ($oHttp.LastMethodSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
$oSbResponseBody = ObjCreate("Chilkat.StringBuilder")
$oResp.GetBodySb($oSbResponseBody)
$oJResp = ObjCreate("Chilkat.JsonObject")
$oJResp.LoadSb($oSbResponseBody)
$oJResp.EmitCompact = False
ConsoleWrite("Response Body:" & @CRLF)
ConsoleWrite($oJResp.Emit() & @CRLF)
Local $iRespStatusCode = $oResp.StatusCode
ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode >= 400) Then
ConsoleWrite("Response Header:" & @CRLF)
ConsoleWrite($oResp.Header & @CRLF)
ConsoleWrite("Failed." & @CRLF)
Exit
EndIf
; Sample JSON response:
; (Sample code for parsing the JSON response is shown below)
; {
; "@odata.context": "https://platform.uipath.com/odata/$metadata#Jobs",
; "value": [
; {
; "Key": "b98fd5c2-0f1d-4d73-903b-30dd22d08ee8",
; "StartTime": null,
; "EndTime": null,
; "State": "Pending",
; "Source": "Manual",
; "SourceType": "Manual",
; "BatchExecutionKey": "16d4ffb5-58d0-44ff-a39a-6cca1f36bc77",
; "Info": null,
; "CreationTime": "2018-07-16T08:30:56.4673722Z",
; "StartingScheduleId": null,
; "ReleaseName": "Process1_playground",
; "Type": "Unattended",
; "Id": 1649897
; }
; ]
; }
; Sample code for parsing the JSON response...
; Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
Local $sKey
Local $sStartTime
Local $sEndTime
Local $sState
Local $sSource
Local $sSourceType
Local $sBatchExecutionKey
Local $sInfo
Local $sCreationTime
Local $sStartingScheduleId
Local $sReleaseName
Local $sV_Type
Local $iId
Local $sOdata_context = $oJResp.StringOf("""@odata.context""")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("value")
While $i < $iCount_i
$oJResp.I = $i
$sKey = $oJResp.StringOf("value[i].Key")
$sStartTime = $oJResp.StringOf("value[i].StartTime")
$sEndTime = $oJResp.StringOf("value[i].EndTime")
$sState = $oJResp.StringOf("value[i].State")
$sSource = $oJResp.StringOf("value[i].Source")
$sSourceType = $oJResp.StringOf("value[i].SourceType")
$sBatchExecutionKey = $oJResp.StringOf("value[i].BatchExecutionKey")
$sInfo = $oJResp.StringOf("value[i].Info")
$sCreationTime = $oJResp.StringOf("value[i].CreationTime")
$sStartingScheduleId = $oJResp.StringOf("value[i].StartingScheduleId")
$sReleaseName = $oJResp.StringOf("value[i].ReleaseName")
$sV_Type = $oJResp.StringOf("value[i].Type")
$iId = $oJResp.IntOf("value[i].Id")
$i = $i + 1
Wend
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
-H "Content-Type: application/json"
-H "X-UIPATH-TenantName: {{tenantName}}"
-H "X-UIPATH-OrganizationUnitId: {{folderId}}"
-d '{ "startInfo":
{ "ReleaseKey": "f689e02d-f968-494f-8b37-409a1bd85534",
"Strategy": "Specific",
"RobotIds": [ 9826 ],
"JobsCount": 0,
"Source": "Manual"
}
}'
https://domain.com/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs
Postman Collection Item JSON
{
"name": "Jobs - Start job",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
},
{
"key": "X-UIPATH-TenantName",
"value": "{{tenantName}}",
"type": "text"
},
{
"key": "X-UIPATH-OrganizationUnitId",
"value": "{{folderId}}",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{ \"startInfo\":\r\n { \"ReleaseKey\": \"f689e02d-f968-494f-8b37-409a1bd85534\",\r\n \"Strategy\": \"Specific\",\r\n \"RobotIds\": [ 9826 ],\r\n \"JobsCount\": 0,\r\n \"Source\": \"Manual\" \r\n } \r\n}"
},
"url": {
"raw": "{{url}}/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs",
"host": [
"{{url}}"
],
"path": [
"odata",
"Jobs",
"UiPath.Server.Configuration.OData.StartJobs"
]
}
},
"response": [
{
"name": "Jobs - Start job",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"disabled": false
}
],
"body": {
"mode": "raw",
"raw": "{ \"startInfo\":\r\n { \"ReleaseKey\": \"f689e02d-f968-494f-8b37-409a1bd85534\",\r\n \"Strategy\": \"Specific\",\r\n \"RobotIds\": [ 9826 ],\r\n \"JobsCount\": 0,\r\n \"Source\": \"Manual\" \r\n } \r\n}"
},
"url": {
"raw": "{{url}}/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs",
"host": [
"{{url}}"
],
"path": [
"odata",
"Jobs",
"UiPath.Server.Configuration.OData.StartJobs"
]
}
},
"status": "Created",
"code": 201,
"_postman_previewlanguage": "json",
"header": [
{
"key": "CF-RAY",
"value": "43b31c105eefbf07-FRA",
"name": "CF-RAY",
"description": "Custom header"
},
{
"key": "Cache-Control",
"value": "no-store, must-revalidate, no-cache, max-age=0",
"name": "Cache-Control",
"description": "Tells all caching mechanisms from server to client whether they may cache this object. It is measured in seconds"
},
{
"key": "Connection",
"value": "keep-alive",
"name": "Connection",
"description": "Options that are desired for the connection"
},
{
"key": "Content-Length",
"value": "425",
"name": "Content-Length",
"description": "The length of the response body in octets (8-bit bytes)"
},
{
"key": "Content-Type",
"value": "application/json; odata.metadata=minimal",
"name": "Content-Type",
"description": "The mime type of this content"
},
{
"key": "Date",
"value": "Mon, 16 Jul 2018 08:30:56 GMT",
"name": "Date",
"description": "The date and time that the message was sent"
},
{
"key": "Expect-CT",
"value": "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"",
"name": "Expect-CT",
"description": "Custom header"
},
{
"key": "OData-Version",
"value": "4.0",
"name": "OData-Version",
"description": "Custom header"
},
{
"key": "Server",
"value": "cloudflare",
"name": "Server",
"description": "A name for the server"
},
{
"key": "Set-Cookie",
"value": "; SameSite=lax",
"name": "Set-Cookie",
"description": "an HTTP cookie"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=31536000; includeSubDomains",
"name": "Strict-Transport-Security",
"description": "A HSTS Policy informing the HTTP client how long to cache the HTTPS only policy and whether this applies to subdomains."
},
{
"key": "X-Content-Type-Options",
"value": "nosniff",
"name": "X-Content-Type-Options",
"description": "The only defined value, \"nosniff\", prevents Internet Explorer from MIME-sniffing a response away from the declared content-type"
},
{
"key": "X-Frame-Options",
"value": "DENY",
"name": "X-Frame-Options",
"description": "Clickjacking protection: \"deny\" - no rendering within a frame, \"sameorigin\" - no rendering if origin mismatch"
},
{
"key": "api-supported-versions",
"value": "5.0",
"name": "api-supported-versions",
"description": "Custom header"
}
],
"cookie": [
{
"expires": "Wed Dec 19 2018 11:35:02 GMT-0600 (Central Standard Time)",
"httpOnly": true,
"domain": "uipath.com",
"path": "/",
"secure": true,
"value": "d3b89a558feb68050f4b847c971f595771513704902",
"key": "__cfduid"
},
{
"expires": "Mon Jan 18 2038 21:14:07 GMT-0600 (Central Standard Time)",
"httpOnly": false,
"domain": "platform.uipath.com",
"path": "/odata/QueueProcessingRecords",
"secure": false,
"value": "",
"key": ""
},
{
"expires": "Mon Jan 18 2038 21:14:07 GMT-0600 (Central Standard Time)",
"httpOnly": false,
"domain": "platform.uipath.com",
"path": "/api/RobotsService",
"secure": false,
"value": "",
"key": ""
},
{
"expires": "Mon Jan 18 2038 21:14:07 GMT-0600 (Central Standard Time)",
"httpOnly": false,
"domain": "platform.uipath.com",
"path": "/odata/Processes",
"secure": false,
"value": "",
"key": ""
},
{
"expires": "Mon Jan 18 2038 21:14:07 GMT-0600 (Central Standard Time)",
"httpOnly": false,
"domain": "platform.uipath.com",
"path": "/odata/Settings",
"secure": false,
"value": "",
"key": ""
},
{
"expires": "Mon Jan 18 2038 21:14:07 GMT-0600 (Central Standard Time)",
"httpOnly": false,
"domain": "platform.uipath.com",
"path": "/odata/Robots",
"secure": false,
"value": "",
"key": ""
},
{
"expires": "Mon Jan 18 2038 21:14:07 GMT-0600 (Central Standard Time)",
"httpOnly": false,
"domain": "platform.uipath.com",
"path": "/odata/Queues",
"secure": false,
"value": "",
"key": ""
},
{
"expires": "Mon Jan 18 2038 21:14:07 GMT-0600 (Central Standard Time)",
"httpOnly": false,
"domain": "platform.uipath.com",
"path": "/odata/Assets",
"secure": false,
"value": "",
"key": ""
},
{
"expires": "Mon Jan 18 2038 21:14:07 GMT-0600 (Central Standard Time)",
"httpOnly": false,
"domain": "platform.uipath.com",
"path": "/api/Account",
"secure": false,
"value": "",
"key": ""
},
{
"expires": "Mon Jan 18 2038 21:14:07 GMT-0600 (Central Standard Time)",
"httpOnly": false,
"domain": "platform.uipath.com",
"path": "/odata/Users",
"secure": false,
"value": "",
"key": ""
},
{
"expires": "Mon Jan 18 2038 21:14:07 GMT-0600 (Central Standard Time)",
"httpOnly": false,
"domain": "platform.uipath.com",
"path": "/odata/Jobs",
"secure": false,
"value": "",
"key": ""
},
{
"expires": "Mon Jan 18 2038 21:14:07 GMT-0600 (Central Standard Time)",
"httpOnly": false,
"domain": "platform.uipath.com",
"path": "/api/Logs",
"secure": false,
"value": "",
"key": ""
},
{
"expires": "Mon Jan 18 2038 21:14:07 GMT-0600 (Central Standard Time)",
"httpOnly": false,
"domain": "platform.uipath.com",
"path": "/Account",
"secure": false,
"value": "",
"key": ""
},
{
"expires": "Mon Jan 18 2038 21:14:07 GMT-0600 (Central Standard Time)",
"httpOnly": false,
"domain": "platform.uipath.com",
"path": "/odata",
"secure": false,
"value": "",
"key": ""
},
{
"expires": "Mon Jan 18 2038 21:14:07 GMT-0600 (Central Standard Time)",
"httpOnly": false,
"domain": "platform.uipath.com",
"path": "/api",
"secure": false,
"value": "",
"key": ""
},
{
"expires": "Mon Jan 18 2038 21:14:07 GMT-0600 (Central Standard Time)",
"httpOnly": false,
"domain": "platform.uipath.com",
"path": "/",
"secure": false,
"value": "",
"key": ""
},
{
"expires": "Mon Jan 18 2038 21:14:07 GMT-0600 (Central Standard Time)",
"httpOnly": false,
"domain": "platform.uipath.com",
"path": "/",
"secure": false,
"value": "GC-osp2U-YDhoXTOqXnUp3DaN1cN_siVCaNVue_jljOcqJLYHQrRk5msz52KHL8XauydRYx_3JyjLtLDpItypCPdEL20jFnxlF2g-f86Qk41",
"key": "__RequestVerificationToken"
}
],
"body": "{\n \"@odata.context\": \"https://platform.uipath.com/odata/$metadata#Jobs\",\n \"value\": [\n {\n \"Key\": \"b98fd5c2-0f1d-4d73-903b-30dd22d08ee8\",\n \"StartTime\": null,\n \"EndTime\": null,\n \"State\": \"Pending\",\n \"Source\": \"Manual\",\n \"SourceType\": \"Manual\",\n \"BatchExecutionKey\": \"16d4ffb5-58d0-44ff-a39a-6cca1f36bc77\",\n \"Info\": null,\n \"CreationTime\": \"2018-07-16T08:30:56.4673722Z\",\n \"StartingScheduleId\": null,\n \"ReleaseName\": \"Process1_playground\",\n \"Type\": \"Unattended\",\n \"Id\": 1649897\n }\n ]\n}"
}
]
}