Chilkat Online Tools

DataFlex / Orchestrator API Documentation / Start Process

Back to Collection Items

Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vJson
    Handle hoJson
    Variant vResp
    Handle hoResp
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    String sKey
    String sStartTime
    String sEndTime
    String sState
    String sJobPriority
    String sSource
    String sSourceType
    String sBatchExecutionKey
    String sInfo
    String sCreationTime
    String sStartingScheduleId
    String sReleaseName
    String sV_Type
    String sInputArguments
    String sOutputArguments
    String sHostMachineName
    Boolean iHasMediaRecorded
    String sPersistenceId
    String sResumeVersion
    String sStopStrategy
    String sRuntimeType
    Boolean iRequiresUserInteraction
    String sReleaseVersionId
    String sEntryPointPath
    Integer iOrganizationUnitId
    String sOrganizationUnitFullyQualifiedName
    String sReference
    String sProcessType
    Integer iId
    String sOdata_context
    Integer i
    Integer iCount_i
    String sTemp1
    Boolean bTemp1

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    // 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}}",
    //     "Strategy": "ModernJobsCount",
    //     "JobsCount": 1,
    //     "InputArguments": "{}"
    //   }
    // }

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "startInfo.ReleaseKey" "{{releaseKey}}" To iSuccess
    Get ComUpdateString Of hoJson "startInfo.Strategy" "ModernJobsCount" To iSuccess
    Get ComUpdateInt Of hoJson "startInfo.JobsCount" 1 To iSuccess
    Get ComUpdateString Of hoJson "startInfo.InputArguments" "{}" To iSuccess

    Send ComSetRequestHeader To hoHttp "Content-Type" "application/json"
    // Adds the "Authorization: Bearer <access_token>" header.
    Set ComAuthToken Of hoHttp To "<access_token>"
    Send ComSetRequestHeader To hoHttp "X-UIPATH-OrganizationUnitId" "{{folderId}}"
    Send ComSetRequestHeader To hoHttp "X-UIPATH-TenantName" "{{tenant}}"

    Get pvComObject of hoJson to vJson
    Get ComPostJson3 Of hoHttp "https://domain.com/orchestrator_/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs" "application/json" vJson To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess

    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
    Set ComEmitCompact Of hoJResp To False

    Showln "Response Body:"
    Get ComEmit Of hoJResp To sTemp1
    Showln sTemp1

    Get ComStatusCode Of hoResp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComHeader Of hoResp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Send Destroy of hoResp
        Procedure_Return
    End

    Send Destroy of hoResp

    // 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": "b07ac1db-13d6-46b7-baf5-51a97ef20946",
    //       "StartTime": null,
    //       "EndTime": null,
    //       "State": "Pending",
    //       "JobPriority": "Normal",
    //       "Source": "Manual",
    //       "SourceType": "Manual",
    //       "BatchExecutionKey": "65bbd1da-623b-4d72-99db-42e70dcb7e52",
    //       "Info": null,
    //       "CreationTime": "2021-03-31T12:54:16.023Z",
    //       "StartingScheduleId": null,
    //       "ReleaseName": "Add a pet to pet store by queue item",
    //       "Type": "Unattended",
    //       "InputArguments": null,
    //       "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": 12764613
    //     }
    //   ]
    // }

    // Sample code for parsing the JSON response...
    // Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    Get ComStringOf Of hoJResp '"@odata.context"' To sOdata_context
    Move 0 To i
    Get ComSizeOfArray Of hoJResp "value" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "value[i].Key" To sKey
        Get ComStringOf Of hoJResp "value[i].StartTime" To sStartTime
        Get ComStringOf Of hoJResp "value[i].EndTime" To sEndTime
        Get ComStringOf Of hoJResp "value[i].State" To sState
        Get ComStringOf Of hoJResp "value[i].JobPriority" To sJobPriority
        Get ComStringOf Of hoJResp "value[i].Source" To sSource
        Get ComStringOf Of hoJResp "value[i].SourceType" To sSourceType
        Get ComStringOf Of hoJResp "value[i].BatchExecutionKey" To sBatchExecutionKey
        Get ComStringOf Of hoJResp "value[i].Info" To sInfo
        Get ComStringOf Of hoJResp "value[i].CreationTime" To sCreationTime
        Get ComStringOf Of hoJResp "value[i].StartingScheduleId" To sStartingScheduleId
        Get ComStringOf Of hoJResp "value[i].ReleaseName" To sReleaseName
        Get ComStringOf Of hoJResp "value[i].Type" To sV_Type
        Get ComStringOf Of hoJResp "value[i].InputArguments" To sInputArguments
        Get ComStringOf Of hoJResp "value[i].OutputArguments" To sOutputArguments
        Get ComStringOf Of hoJResp "value[i].HostMachineName" To sHostMachineName
        Get ComBoolOf Of hoJResp "value[i].HasMediaRecorded" To iHasMediaRecorded
        Get ComStringOf Of hoJResp "value[i].PersistenceId" To sPersistenceId
        Get ComStringOf Of hoJResp "value[i].ResumeVersion" To sResumeVersion
        Get ComStringOf Of hoJResp "value[i].StopStrategy" To sStopStrategy
        Get ComStringOf Of hoJResp "value[i].RuntimeType" To sRuntimeType
        Get ComBoolOf Of hoJResp "value[i].RequiresUserInteraction" To iRequiresUserInteraction
        Get ComStringOf Of hoJResp "value[i].ReleaseVersionId" To sReleaseVersionId
        Get ComStringOf Of hoJResp "value[i].EntryPointPath" To sEntryPointPath
        Get ComIntOf Of hoJResp "value[i].OrganizationUnitId" To iOrganizationUnitId
        Get ComStringOf Of hoJResp "value[i].OrganizationUnitFullyQualifiedName" To sOrganizationUnitFullyQualifiedName
        Get ComStringOf Of hoJResp "value[i].Reference" To sReference
        Get ComStringOf Of hoJResp "value[i].ProcessType" To sProcessType
        Get ComIntOf Of hoJResp "value[i].Id" To iId
        Move (i + 1) To i
    Loop



End_Procedure

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: application/json"
	-H "X-UIPATH-TenantName: {{tenant}}"
	-H "X-UIPATH-OrganizationUnitId: {{folderId}}"
	-d '{
    "startInfo": {
        "ReleaseKey": "{{releaseKey}}",
        "Strategy": "ModernJobsCount",
        "JobsCount": 1,
        "InputArguments": "{}"
    }
}'
https://domain.com/orchestrator_/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-TenantName",
        "value": "{{tenant}}",
        "type": "text"
      },
      {
        "key": "X-UIPATH-OrganizationUnitId",
        "value": "{{folderId}}",
        "type": "text"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\r\n    \"startInfo\": {\r\n        \"ReleaseKey\": \"{{releaseKey}}\",\r\n        \"Strategy\": \"ModernJobsCount\",\r\n        \"JobsCount\": 1,\r\n        \"InputArguments\": \"{}\"\r\n    }\r\n}"
    },
    "url": {
      "raw": "{{url}}/orchestrator_/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs",
      "host": [
        "{{url}}"
      ],
      "path": [
        "orchestrator_",
        "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 the next 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",
            "name": "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": "{\r\n    \"startInfo\": {\r\n        \"ReleaseKey\": \"{{releaseKey}}\",\r\n        \"Strategy\": \"ModernJobsCount\",\r\n        \"JobsCount\": 1,\r\n        \"InputArguments\": \"{}\"\r\n    }\r\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "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": "Wed, 31 Mar 2021 12:54:16 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": "f037b495-9025-4cb3-a4aa-c5bcc7cfa38b"
        },
        {
          "key": "OData-Version",
          "value": "4.0"
        },
        {
          "key": "api-supported-versions",
          "value": "12.0"
        },
        {
          "key": "CF-Cache-Status",
          "value": "DYNAMIC"
        },
        {
          "key": "cf-request-id",
          "value": "0929f25fdf0000cba02d06c000000001"
        },
        {
          "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": "6389b9ac9b2ecba0-VIE"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"@odata.context\": \"https://cloud.uipath.com/org/tenant/orchestrator_/odata/$metadata#Jobs\",\n    \"value\": [\n        {\n            \"Key\": \"b07ac1db-13d6-46b7-baf5-51a97ef20946\",\n            \"StartTime\": null,\n            \"EndTime\": null,\n            \"State\": \"Pending\",\n            \"JobPriority\": \"Normal\",\n            \"Source\": \"Manual\",\n            \"SourceType\": \"Manual\",\n            \"BatchExecutionKey\": \"65bbd1da-623b-4d72-99db-42e70dcb7e52\",\n            \"Info\": null,\n            \"CreationTime\": \"2021-03-31T12:54:16.023Z\",\n            \"StartingScheduleId\": null,\n            \"ReleaseName\": \"Add a pet to pet store by queue item\",\n            \"Type\": \"Unattended\",\n            \"InputArguments\": null,\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\": 12764613\n        }\n    ]\n}"
    }
  ]
}