Chilkat Online Tools

PureBasic / Orchestrator / 2. Releases - Get by name

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

    queryParams.i = CkJsonObject::ckCreate()
    If queryParams.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkJsonObject::ckUpdateString(queryParams,"$filter","ProcessKey eq 'Hello'")

    ; Adds the "Authorization: Bearer <access_token>" header.
    CkHttp::setCkAuthToken(http, "<access_token>")
    CkHttp::ckSetRequestHeader(http,"X-UIPATH-OrganizationUnitId","{{folderId}}")
    CkHttp::ckSetRequestHeader(http,"X-UIPATH-TenantName","{{tenantName}}")

    resp.i = CkHttp::ckQuickRequestParams(http,"GET","https://domain.com/odata/Releases",queryParams)
    If CkHttp::ckLastMethodSuccess(http) = 0
        Debug CkHttp::ckLastErrorText(http)
        CkHttp::ckDispose(http)
        CkJsonObject::ckDispose(queryParams)
        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(queryParams)
        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://platform.uipath.com/odata/$metadata#Releases",
    ;   "@odata.count": 1,
    ;   "value": [
    ;     {
    ;       "Key": "0764f4a-2ce0-41b9-r738-4575566f3756",
    ;       "ProcessKey": "Hello",
    ;       "ProcessVersion": "1.0.6913.24377",
    ;       "IsLatestVersion": false,
    ;       "IsProcessDeleted": false,
    ;       "Description": null,
    ;       "Name": "Hello_playground",
    ;       "EnvironmentId": 3210,
    ;       "EnvironmentName": "playground",
    ;       "InputArguments": "{}",
    ;       "QueueDefinitionId": null,
    ;       "QueueDefinitionName": null,
    ;       "Id": 12345,
    ;       "Arguments": {
    ;         "Input": "[{\"name\":\"greeting\",\"type\":\"System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\",\"required\":false,\"hasDefault\":false},{\"name\":\"url\",\"type\":\"System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\",\"required\":false,\"hasDefault\":false},{\"name\":\"username\",\"type\":\"System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\",\"required\":false,\"hasDefault\":true},{\"name\":\"password\",\"type\":\"System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\",\"required\":false,\"hasDefault\":true}]",
    ;         "Output": "[{\"name\":\"greeting\",\"type\":\"System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\",\"required\":false,\"hasDefault\":false}]"
    ;       },
    ;       "ProcessSettings": null
    ;     }
    ;   ]
    ; }

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

    Key.s
    ProcessKey.s
    ProcessVersion.s
    IsLatestVersion.i
    IsProcessDeleted.i
    Description.s
    Name.s
    EnvironmentId.i
    EnvironmentName.s
    InputArguments.s
    QueueDefinitionId.s
    QueueDefinitionName.s
    Id.i
    Input.s
    Output.s
    ProcessSettings.s

    odata_context.s = CkJsonObject::ckStringOf(jResp,Chr(34) + "@odata.context" + Chr(34))
    odata_count.i = CkJsonObject::ckIntOf(jResp,Chr(34) + "@odata.count" + 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")
        ProcessKey = CkJsonObject::ckStringOf(jResp,"value[i].ProcessKey")
        ProcessVersion = CkJsonObject::ckStringOf(jResp,"value[i].ProcessVersion")
        IsLatestVersion = CkJsonObject::ckBoolOf(jResp,"value[i].IsLatestVersion")
        IsProcessDeleted = CkJsonObject::ckBoolOf(jResp,"value[i].IsProcessDeleted")
        Description = CkJsonObject::ckStringOf(jResp,"value[i].Description")
        Name = CkJsonObject::ckStringOf(jResp,"value[i].Name")
        EnvironmentId = CkJsonObject::ckIntOf(jResp,"value[i].EnvironmentId")
        EnvironmentName = CkJsonObject::ckStringOf(jResp,"value[i].EnvironmentName")
        InputArguments = CkJsonObject::ckStringOf(jResp,"value[i].InputArguments")
        QueueDefinitionId = CkJsonObject::ckStringOf(jResp,"value[i].QueueDefinitionId")
        QueueDefinitionName = CkJsonObject::ckStringOf(jResp,"value[i].QueueDefinitionName")
        Id = CkJsonObject::ckIntOf(jResp,"value[i].Id")
        Input = CkJsonObject::ckStringOf(jResp,"value[i].Arguments.Input")
        Output = CkJsonObject::ckStringOf(jResp,"value[i].Arguments.Output")
        ProcessSettings = CkJsonObject::ckStringOf(jResp,"value[i].ProcessSettings")
        i = i + 1
    Wend


    CkHttp::ckDispose(http)
    CkJsonObject::ckDispose(queryParams)
    CkStringBuilder::ckDispose(sbResponseBody)
    CkJsonObject::ckDispose(jResp)


    ProcedureReturn
EndProcedure

Curl Command

curl -G -d "$filter=ProcessKey%20eq%20%27Hello%27"
	-H "Authorization: Bearer <access_token>"
	-H "X-UIPATH-TenantName: {{tenantName}}"
	-H "X-UIPATH-OrganizationUnitId: {{folderId}}"
https://domain.com/odata/Releases

Postman Collection Item JSON

{
  "name": "2. Releases - Get by name",
  "event": [
    {
      "listen": "test",
      "script": {
        "exec": [
          ""
        ],
        "type": "text/javascript"
      }
    }
  ],
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "X-UIPATH-TenantName",
        "value": "{{tenantName}}",
        "type": "text"
      },
      {
        "key": "X-UIPATH-OrganizationUnitId",
        "value": "{{folderId}}",
        "type": "text"
      }
    ],
    "url": {
      "raw": "{{url}}/odata/Releases?$filter=ProcessKey eq 'Hello'",
      "host": [
        "{{url}}"
      ],
      "path": [
        "odata",
        "Releases"
      ],
      "query": [
        {
          "key": "$filter",
          "value": "ProcessKey eq 'Hello'"
        }
      ]
    },
    "description": "So you've created a **Process** in UiPath Studio and published it to Orchestrator. Here's where you specify that process, by name, in order to start it remotely.\n\nWithin the URL, simply replace the word `Hello` with the name of your process and this call will return the `ReleaseKey` that will identify your process in step 4."
  },
  "response": [
    {
      "name": "2. Get the Process",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{url}}/odata/Releases?$filter=ProcessKey eq 'Hello'",
          "host": [
            "{{url}}"
          ],
          "path": [
            "odata",
            "Releases"
          ],
          "query": [
            {
              "key": "$filter",
              "value": "ProcessKey eq 'Hello'"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Date",
          "value": "Wed, 03 Jul 2019 23:08:51 GMT"
        },
        {
          "key": "Content-Type",
          "value": "application/json; odata.metadata=minimal"
        },
        {
          "key": "Transfer-Encoding",
          "value": "chunked"
        },
        {
          "key": "Connection",
          "value": "keep-alive"
        },
        {
          "key": "Cache-Control",
          "value": "no-store, must-revalidate, no-cache, max-age=0"
        },
        {
          "key": "Content-Encoding",
          "value": "gzip"
        },
        {
          "key": "Vary",
          "value": "Accept-Encoding"
        },
        {
          "key": "api-supported-versions",
          "value": "8.0"
        },
        {
          "key": "OData-Version",
          "value": "4.0"
        },
        {
          "key": "X-Content-Type-Options",
          "value": "nosniff"
        },
        {
          "key": "X-Frame-Options",
          "value": "DENY"
        },
        {
          "key": "Strict-Transport-Security",
          "value": "max-age=31536000; includeSubDomains"
        },
        {
          "key": "Set-Cookie",
          "value": "; SameSite=lax"
        },
        {
          "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": "4f0c85eb7e8c3892-ATL"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"@odata.context\": \"https://platform.uipath.com/odata/$metadata#Releases\",\n    \"@odata.count\": 1,\n    \"value\": [\n        {\n            \"Key\": \"0764f4a-2ce0-41b9-r738-4575566f3756\",\n            \"ProcessKey\": \"Hello\",\n            \"ProcessVersion\": \"1.0.6913.24377\",\n            \"IsLatestVersion\": false,\n            \"IsProcessDeleted\": false,\n            \"Description\": null,\n            \"Name\": \"Hello_playground\",\n            \"EnvironmentId\": 3210,\n            \"EnvironmentName\": \"playground\",\n            \"InputArguments\": \"{}\",\n            \"QueueDefinitionId\": null,\n            \"QueueDefinitionName\": null,\n            \"Id\": 12345,\n            \"Arguments\": {\n                \"Input\": \"[{\\\"name\\\":\\\"greeting\\\",\\\"type\\\":\\\"System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\\\",\\\"required\\\":false,\\\"hasDefault\\\":false},{\\\"name\\\":\\\"url\\\",\\\"type\\\":\\\"System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\\\",\\\"required\\\":false,\\\"hasDefault\\\":false},{\\\"name\\\":\\\"username\\\",\\\"type\\\":\\\"System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\\\",\\\"required\\\":false,\\\"hasDefault\\\":true},{\\\"name\\\":\\\"password\\\",\\\"type\\\":\\\"System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\\\",\\\"required\\\":false,\\\"hasDefault\\\":true}]\",\n                \"Output\": \"[{\\\"name\\\":\\\"greeting\\\",\\\"type\\\":\\\"System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\\\",\\\"required\\\":false,\\\"hasDefault\\\":false}]\"\n            },\n            \"ProcessSettings\": null\n        }\n    ]\n}"
    }
  ]
}