Chilkat Online Tools

PureBasic / Orchestrator API Documentation / Start Transaction

Back to Collection Items

IncludeFile "CkJsonObject.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.

    ; {
    ;   "transactionData": {
    ;     "Name": "UnattendedQueue",
    ;     "RobotIdentifier": "863426ab-b299-4184-af7d-285a1ead6582"
    ;   }
    ; }

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

    CkJsonObject::ckUpdateString(json,"transactionData.Name","UnattendedQueue")
    CkJsonObject::ckUpdateString(json,"transactionData.RobotIdentifier","863426ab-b299-4184-af7d-285a1ead6582")

    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/orchestrator_/odata/Queues/UiPathODataSvc.StartTransaction","application/json",json)
    If CkHttp::ckLastMethodSuccess(http) = 0
        Debug CkHttp::ckLastErrorText(http)
        CkHttp::ckDispose(http)
        CkJsonObject::ckDispose(json)
        ProcedureReturn
    EndIf

    Debug Str(CkHttpResponse::ckStatusCode(resp))
    Debug CkHttpResponse::ckBodyStr(resp)
    CkHttpResponse::ckDispose(resp)



    CkHttp::ckDispose(http)
    CkJsonObject::ckDispose(json)


    ProcedureReturn
EndProcedure

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: application/json"
	-H "X-UIPATH-OrganizationUnitId: {{folderId}}"
	-d '{
  "transactionData": {
    "Name": "UnattendedQueue",
    "RobotIdentifier": "863426ab-b299-4184-af7d-285a1ead6582"
  }
}'
https://domain.com/orchestrator_/odata/Queues/UiPathODataSvc.StartTransaction

Postman Collection Item JSON

{
  "name": "Start Transaction",
  "event": [
    {
      "listen": "test",
      "script": {
        "exec": [
          "pm.test(\"Status code is 200\", function () {\r",
          "    pm.response.to.have.status(200);\r",
          "});"
        ],
        "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  \"transactionData\": {\r\n    \"Name\": \"UnattendedQueue\",\r\n    \"RobotIdentifier\": \"863426ab-b299-4184-af7d-285a1ead6582\"\r\n  }\r\n}"
    },
    "url": {
      "raw": "{{url}}/orchestrator_/odata/Queues/UiPathODataSvc.StartTransaction",
      "host": [
        "{{url}}"
      ],
      "path": [
        "orchestrator_",
        "odata",
        "Queues",
        "UiPathODataSvc.StartTransaction"
      ]
    }
  },
  "response": [
    {
      "name": "Start Transaction",
      "originalRequest": {
        "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": "{\r\n  \"transactionData\": {\r\n    \"Name\": \"UnattendedQueue\",\r\n    \"RobotIdentifier\": \"863426ab-b299-4184-af7d-285a1ead6582\"\r\n  }\r\n}"
        },
        "url": {
          "raw": "{{url}}/orchestrator_/odata/Queues/UiPathODataSvc.StartTransaction",
          "host": [
            "{{url}}"
          ],
          "path": [
            "orchestrator_",
            "odata",
            "Queues",
            "UiPathODataSvc.StartTransaction"
          ]
        }
      },
      "status": "No Content",
      "code": 204,
      "_postman_previewlanguage": "plain",
      "header": [
        {
          "key": "Date",
          "value": "Wed, 31 Mar 2021 12:55:13 GMT"
        },
        {
          "key": "Content-Length",
          "value": "0"
        },
        {
          "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": "a3b97919-ab81-4d16-88ff-46b32a822a88"
        },
        {
          "key": "api-supported-versions",
          "value": "12.0"
        },
        {
          "key": "CF-Cache-Status",
          "value": "DYNAMIC"
        },
        {
          "key": "cf-request-id",
          "value": "0929f3402a0000cba02d2d3000000001"
        },
        {
          "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": "6389bb137ad3cba0-VIE"
        }
      ],
      "cookie": [
      ],
      "body": null
    }
  ]
}