Back to Collection Items
IncludeFile "CkJsonObject.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkHttpResponse.pb"
Procedure ChilkatExample()
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
http.i = CkHttp::ckCreate()
If http.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
; 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": "{{releaseKey}}",
; "JobsCount": 1,
; "JobPriority": "Normal",
; "Strategy": "ModernJobsCount",
; "RuntimeType": "Unattended",
; "InputArguments": "{\"ProcessArguments\":[{\"OrderedItems\":\"0\",\"Product ID\":\"000010\",\"SAP Order ID\":\"NA\",\"Measure Names\":\"Sales Forecast\",\"Measure Values\":\"$2 555\"},{\"OrderedItems\":\"0\",\"Product ID\":\"000010\",\"SAP Order ID\":\"NA\",\"Measure Names\":\"Quantity\",\"Measure Values\":\"1\"},{\"OrderedItems\":\"0\",\"Product ID\":\"000010\",\"SAP Order ID\":\"NA\",\"Measure Names\":\"OrderSize\",\"Measure Values\":\"5\"}]}"
; }
; }
json.i = CkJsonObject::ckCreate()
If json.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckUpdateString(json,"startInfo.ReleaseKey","{{releaseKey}}")
CkJsonObject::ckUpdateInt(json,"startInfo.JobsCount",1)
CkJsonObject::ckUpdateString(json,"startInfo.JobPriority","Normal")
CkJsonObject::ckUpdateString(json,"startInfo.Strategy","ModernJobsCount")
CkJsonObject::ckUpdateString(json,"startInfo.RuntimeType","Unattended")
CkJsonObject::ckUpdateString(json,"startInfo.InputArguments","{" + Chr(34) + "ProcessArguments" + Chr(34) + ":[{" + Chr(34) + "OrderedItems" + Chr(34) + ":" + Chr(34) + "0" + Chr(34) + "," + Chr(34) + "Product ID" + Chr(34) + ":" + Chr(34) + "000010" + Chr(34) + "," + Chr(34) + "SAP Order ID" + Chr(34) + ":" + Chr(34) + "NA" + Chr(34) + "," + Chr(34) + "Measure Names" + Chr(34) + ":" + Chr(34) + "Sales Forecast" + Chr(34) + "," + Chr(34) + "Measure Values" + Chr(34) + ":" + Chr(34) + "$2 555" + Chr(34) + "},{" + Chr(34) + "OrderedItems" + Chr(34) + ":" + Chr(34) + "0" + Chr(34) + "," + Chr(34) + "Product ID" + Chr(34) + ":" + Chr(34) + "000010" + Chr(34) + "," + Chr(34) + "SAP Order ID" + Chr(34) + ":" + Chr(34) + "NA" + Chr(34) + "," + Chr(34) + "Measure Names" + Chr(34) + ":" + Chr(34) + "Quantity" + Chr(34) + "," + Chr(34) + "Measure Values" + Chr(34) + ":" + Chr(34) + "1" + Chr(34) + "},{" + Chr(34) + "OrderedItems" + Chr(34) + ":" + Chr(34) + "0" + Chr(34) + "," + Chr(34) + "Product ID" + Chr(34) + ":" + Chr(34) + "000010" + Chr(34) + "," + Chr(34) + "SAP Order ID" + Chr(34) + ":" + Chr(34) + "NA" + Chr(34) + "," + Chr(34) + "Measure Names" + Chr(34) + ":" + Chr(34) + "OrderSize" + Chr(34) + "," + Chr(34) + "Measure Values" + Chr(34) + ":" + Chr(34) + "5" + Chr(34) + "}]}")
CkHttp::ckSetRequestHeader(http,"Content-Type","application/json")
; Adds the "Authorization: Bearer <access_token>" header.
CkHttp::setCkAuthToken(http, "<access_token>")
CkHttp::ckSetRequestHeader(http,"X-UIPATH-OrganizationUnitId","{{folderId}}")
resp.i = CkHttp::ckPostJson3(http,"https://domain.com/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs","application/json",json)
If CkHttp::ckLastMethodSuccess(http) = 0
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
CkJsonObject::ckDispose(json)
ProcedureReturn
EndIf
sbResponseBody.i = CkStringBuilder::ckCreate()
If sbResponseBody.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkHttpResponse::ckGetBodySb(resp,sbResponseBody)
jResp.i = CkJsonObject::ckCreate()
If jResp.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckLoadSb(jResp,sbResponseBody)
CkJsonObject::setCkEmitCompact(jResp, 0)
Debug "Response Body:"
Debug CkJsonObject::ckEmit(jResp)
respStatusCode.i = CkHttpResponse::ckStatusCode(resp)
Debug "Response Status Code = " + Str(respStatusCode)
If respStatusCode >= 400
Debug "Response Header:"
Debug CkHttpResponse::ckHeader(resp)
Debug "Failed."
CkHttpResponse::ckDispose(resp)
CkHttp::ckDispose(http)
CkJsonObject::ckDispose(json)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonObject::ckDispose(jResp)
ProcedureReturn
EndIf
CkHttpResponse::ckDispose(resp)
; Sample JSON response:
; (Sample code for parsing the JSON response is shown below)
; {
; "@odata.context": "https://cloud.uipath.com/org/tenant/orchestrator_/odata/$metadata#Jobs",
; "value": [
; {
; "Key": "4d7ea00a-996b-4a7d-961b-9068d9a519b3",
; "StartTime": null,
; "EndTime": null,
; "State": "Pending",
; "JobPriority": "Normal",
; "Source": "Manual",
; "SourceType": "Manual",
; "BatchExecutionKey": "1e089817-98da-4dd0-b527-7aea211c4ef9",
; "Info": null,
; "CreationTime": "2021-04-20T09:06:13.78Z",
; "StartingScheduleId": null,
; "ReleaseName": "Update existsing pet by ID",
; "Type": "Unattended",
; "InputArguments": "{\"status\":\"Sold\"}",
; "OutputArguments": null,
; "HostMachineName": null,
; "HasMediaRecorded": false,
; "PersistenceId": null,
; "ResumeVersion": null,
; "StopStrategy": null,
; "RuntimeType": "Unattended",
; "RequiresUserInteraction": true,
; "ReleaseVersionId": null,
; "EntryPointPath": null,
; "OrganizationUnitId": 515128,
; "OrganizationUnitFullyQualifiedName": null,
; "Reference": "",
; "ProcessType": "Process",
; "Id": 14435785
; }
; ]
; }
; Sample code for parsing the JSON response...
; Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
Key.s
StartTime.s
EndTime.s
State.s
JobPriority.s
Source.s
SourceType.s
BatchExecutionKey.s
Info.s
CreationTime.s
StartingScheduleId.s
ReleaseName.s
v_Type.s
InputArguments.s
OutputArguments.s
HostMachineName.s
HasMediaRecorded.i
PersistenceId.s
ResumeVersion.s
StopStrategy.s
RuntimeType.s
RequiresUserInteraction.i
ReleaseVersionId.s
EntryPointPath.s
OrganizationUnitId.i
OrganizationUnitFullyQualifiedName.s
Reference.s
ProcessType.s
Id.i
odata_context.s = CkJsonObject::ckStringOf(jResp,Chr(34) + "@odata.context" + Chr(34))
i.i = 0
count_i.i = CkJsonObject::ckSizeOfArray(jResp,"value")
While i < count_i
CkJsonObject::setCkI(jResp, i)
Key = CkJsonObject::ckStringOf(jResp,"value[i].Key")
StartTime = CkJsonObject::ckStringOf(jResp,"value[i].StartTime")
EndTime = CkJsonObject::ckStringOf(jResp,"value[i].EndTime")
State = CkJsonObject::ckStringOf(jResp,"value[i].State")
JobPriority = CkJsonObject::ckStringOf(jResp,"value[i].JobPriority")
Source = CkJsonObject::ckStringOf(jResp,"value[i].Source")
SourceType = CkJsonObject::ckStringOf(jResp,"value[i].SourceType")
BatchExecutionKey = CkJsonObject::ckStringOf(jResp,"value[i].BatchExecutionKey")
Info = CkJsonObject::ckStringOf(jResp,"value[i].Info")
CreationTime = CkJsonObject::ckStringOf(jResp,"value[i].CreationTime")
StartingScheduleId = CkJsonObject::ckStringOf(jResp,"value[i].StartingScheduleId")
ReleaseName = CkJsonObject::ckStringOf(jResp,"value[i].ReleaseName")
v_Type = CkJsonObject::ckStringOf(jResp,"value[i].Type")
InputArguments = CkJsonObject::ckStringOf(jResp,"value[i].InputArguments")
OutputArguments = CkJsonObject::ckStringOf(jResp,"value[i].OutputArguments")
HostMachineName = CkJsonObject::ckStringOf(jResp,"value[i].HostMachineName")
HasMediaRecorded = CkJsonObject::ckBoolOf(jResp,"value[i].HasMediaRecorded")
PersistenceId = CkJsonObject::ckStringOf(jResp,"value[i].PersistenceId")
ResumeVersion = CkJsonObject::ckStringOf(jResp,"value[i].ResumeVersion")
StopStrategy = CkJsonObject::ckStringOf(jResp,"value[i].StopStrategy")
RuntimeType = CkJsonObject::ckStringOf(jResp,"value[i].RuntimeType")
RequiresUserInteraction = CkJsonObject::ckBoolOf(jResp,"value[i].RequiresUserInteraction")
ReleaseVersionId = CkJsonObject::ckStringOf(jResp,"value[i].ReleaseVersionId")
EntryPointPath = CkJsonObject::ckStringOf(jResp,"value[i].EntryPointPath")
OrganizationUnitId = CkJsonObject::ckIntOf(jResp,"value[i].OrganizationUnitId")
OrganizationUnitFullyQualifiedName = CkJsonObject::ckStringOf(jResp,"value[i].OrganizationUnitFullyQualifiedName")
Reference = CkJsonObject::ckStringOf(jResp,"value[i].Reference")
ProcessType = CkJsonObject::ckStringOf(jResp,"value[i].ProcessType")
Id = CkJsonObject::ckIntOf(jResp,"value[i].Id")
i = i + 1
Wend
CkHttp::ckDispose(http)
CkJsonObject::ckDispose(json)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonObject::ckDispose(jResp)
ProcedureReturn
EndProcedure
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
-H "Content-Type: application/json"
-H "X-UIPATH-OrganizationUnitId: {{folderId}}"
-d '{
"startInfo": {
"ReleaseKey": "{{releaseKey}}",
"JobsCount": 1,
"JobPriority": "Normal",
"Strategy": "ModernJobsCount",
"RuntimeType": "Unattended",
"InputArguments": "{\"ProcessArguments\":[{\"OrderedItems\":\"0\",\"Product ID\":\"000010\",\"SAP Order ID\":\"NA\",\"Measure Names\":\"Sales Forecast\",\"Measure Values\":\"$2 555\"},{\"OrderedItems\":\"0\",\"Product ID\":\"000010\",\"SAP Order ID\":\"NA\",\"Measure Names\":\"Quantity\",\"Measure Values\":\"1\"},{\"OrderedItems\":\"0\",\"Product ID\":\"000010\",\"SAP Order ID\":\"NA\",\"Measure Names\":\"OrderSize\",\"Measure Values\":\"5\"}]}"
}
}'
https://domain.com/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs
Postman Collection Item JSON
{
"name": "Start Process",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 201\", function () {\r",
" pm.response.to.have.status(201);\r",
"});\r",
"\r",
"//set JobId key\r",
"var myResponse = pm.response.json();\r",
"pm.collectionVariables.set(\"jobId\", myResponse.value[0].Id);\r",
"console.log(pm.collectionVariables.get(\"jobId\"));"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
},
{
"key": "X-UIPATH-OrganizationUnitId",
"value": "{{folderId}}",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"startInfo\": {\r\n \"ReleaseKey\": \"{{releaseKey}}\",\r\n \"JobsCount\": 1,\r\n \"JobPriority\": \"Normal\",\r\n \"Strategy\": \"ModernJobsCount\",\r\n \"RuntimeType\": \"Unattended\",\r\n \"InputArguments\": \"{\\\"ProcessArguments\\\":[{\\\"OrderedItems\\\":\\\"0\\\",\\\"Product ID\\\":\\\"000010\\\",\\\"SAP Order ID\\\":\\\"NA\\\",\\\"Measure Names\\\":\\\"Sales Forecast\\\",\\\"Measure Values\\\":\\\"$2 555\\\"},{\\\"OrderedItems\\\":\\\"0\\\",\\\"Product ID\\\":\\\"000010\\\",\\\"SAP Order ID\\\":\\\"NA\\\",\\\"Measure Names\\\":\\\"Quantity\\\",\\\"Measure Values\\\":\\\"1\\\"},{\\\"OrderedItems\\\":\\\"0\\\",\\\"Product ID\\\":\\\"000010\\\",\\\"SAP Order ID\\\":\\\"NA\\\",\\\"Measure Names\\\":\\\"OrderSize\\\",\\\"Measure Values\\\":\\\"5\\\"}]}\"\r\n }\r\n}"
},
"url": {
"raw": "{{url}}/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs",
"host": [
"{{url}}"
],
"path": [
"odata",
"Jobs",
"UiPath.Server.Configuration.OData.StartJobs"
]
},
"description": "Within Orchestrator, a **Process** that is running or has been run is called a **Job**. To start a **Job** you need to hand over at least the following request body input parameters:\n\n1. `ReleaseKey`: The ID you get in the previous step _GET Releases by name_. The Orchestator needs this key to run a specific version of a process.\n2. `Strategy`: For modern folders we recommend to make use of _ModernJobsCount_.\n3. `JobsCount`: How often the job will be executed.\n4. `InputArguments`: If your job has input parameters, they can be sent as a JSON string in the _InputArguments_ field. If it does not, this field will be ignored. See how input arguments are handed over in this example.\n\nFind more details on how to start of job [here](https://docs.uipath.com/orchestrator/docs/managing-jobs)."
},
"response": [
{
"name": "Start Process",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
},
{
"key": "X-UIPATH-OrganizationUnitId",
"value": "{{folderId}}",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"startInfo\": {\r\n \"ReleaseKey\": \"{{releaseKey}}\",\r\n \"JobsCount\": 1,\r\n \"JobPriority\": \"Normal\",\r\n \"Strategy\": \"ModernJobsCount\",\r\n \"RuntimeType\": \"Unattended\",\r\n \"InputArguments\": \"{\\\"status\\\":\\\"Sold\\\"}\"\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": "Date",
"value": "Tue, 20 Apr 2021 09:06:13 GMT"
},
{
"key": "Content-Type",
"value": "application/json; odata.metadata=minimal; odata.streaming=true"
},
{
"key": "Transfer-Encoding",
"value": "chunked"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "Cache-Control",
"value": "no-cache, no-store, must-revalidate"
},
{
"key": "Pragma",
"value": "no-cache"
},
{
"key": "Expires",
"value": "-1"
},
{
"key": "Request-Context",
"value": "appId=cid-v1:04884d99-0742-441b-a23c-847133cb0130"
},
{
"key": "X-Robots-Tag",
"value": "noindex,nofollow"
},
{
"key": "X-Download-Options",
"value": "noopen"
},
{
"key": "X-XSS-Protection",
"value": "1"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-Frame-Options",
"value": "Deny"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=31536000; includeSubDomains"
},
{
"key": "Content-Security-Policy",
"value": "default-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: https://*.blob.core.windows.net https://*.amazonaws.com blob:;font-src 'self' data:;connect-src 'self' wss: https://sentry.io https://studio-feedback.azure-api.net https://storage.googleapis.com https://*.service.signalr.net https://*.blob.core.windows.net https://*.amazonaws.com dc.services.visualstudio.com;worker-src 'self' blob:"
},
{
"key": "X-Correlation-ID",
"value": "9dca99ab-1885-4420-830c-e3490ae41aad"
},
{
"key": "OData-Version",
"value": "4.0"
},
{
"key": "api-supported-versions",
"value": "12.0"
},
{
"key": "CF-Cache-Status",
"value": "DYNAMIC"
},
{
"key": "cf-request-id",
"value": "099020c99a00000fae930af000000001"
},
{
"key": "Expect-CT",
"value": "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""
},
{
"key": "Server",
"value": "cloudflare"
},
{
"key": "CF-RAY",
"value": "642d37228be00fae-VIE"
}
],
"cookie": [
],
"body": "{\n \"@odata.context\": \"https://cloud.uipath.com/org/tenant/orchestrator_/odata/$metadata#Jobs\",\n \"value\": [\n {\n \"Key\": \"4d7ea00a-996b-4a7d-961b-9068d9a519b3\",\n \"StartTime\": null,\n \"EndTime\": null,\n \"State\": \"Pending\",\n \"JobPriority\": \"Normal\",\n \"Source\": \"Manual\",\n \"SourceType\": \"Manual\",\n \"BatchExecutionKey\": \"1e089817-98da-4dd0-b527-7aea211c4ef9\",\n \"Info\": null,\n \"CreationTime\": \"2021-04-20T09:06:13.78Z\",\n \"StartingScheduleId\": null,\n \"ReleaseName\": \"Update existsing pet by ID\",\n \"Type\": \"Unattended\",\n \"InputArguments\": \"{\\\"status\\\":\\\"Sold\\\"}\",\n \"OutputArguments\": null,\n \"HostMachineName\": null,\n \"HasMediaRecorded\": false,\n \"PersistenceId\": null,\n \"ResumeVersion\": null,\n \"StopStrategy\": null,\n \"RuntimeType\": \"Unattended\",\n \"RequiresUserInteraction\": true,\n \"ReleaseVersionId\": null,\n \"EntryPointPath\": null,\n \"OrganizationUnitId\": 515128,\n \"OrganizationUnitFullyQualifiedName\": null,\n \"Reference\": \"\",\n \"ProcessType\": \"Process\",\n \"Id\": 14435785\n }\n ]\n}"
}
]
}