Chilkat Online Tools

DataFlex / Orchestrator / Queue Items - Create

Back to Collection Items

Use ChilkatAx-9.5.0-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 sOdata_context
    Integer iQueueDefinitionId
    String sOutputData
    String sStatus
    String sReviewStatus
    String sReviewerUserId
    String sKey
    String sReference
    String sProcessingExceptionType
    String sDueDate
    String sPriority
    String sDeferDate
    String sStartProcessing
    String sEndProcessing
    Integer iSecondsInPreviousAttempts
    String sAncestorId
    Integer iRetryNumber
    String sSpecificData
    String sCreationTime
    String sProgress
    String sRowVersion
    Integer iId
    String sProcessingException
    String sV_Type
    String sName
    String sOutput
    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.

    // {
    //   "itemData": {
    //     "Name": "TestQueue",
    //     "Priority": "Normal",
    //     "SpecificContent": {
    //       "First": "Some String Value Here",
    //       "First@odata.type": "#String",
    //       "Second": 516,
    //       "Fourth": "Did I skip the Third value?",
    //       "AnotherKey": true
    //     }
    //   }
    // }

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "itemData.Name" "TestQueue" To iSuccess
    Get ComUpdateString Of hoJson "itemData.Priority" "Normal" To iSuccess
    Get ComUpdateString Of hoJson "itemData.SpecificContent.First" "Some String Value Here" To iSuccess
    Get ComUpdateString Of hoJson 'itemData.SpecificContent."First@odata.type"' "#String" To iSuccess
    Get ComUpdateInt Of hoJson "itemData.SpecificContent.Second" 516 To iSuccess
    Get ComUpdateString Of hoJson "itemData.SpecificContent.Fourth" "Did I skip the Third value?" To iSuccess
    Get ComUpdateBool Of hoJson "itemData.SpecificContent.AnotherKey" True 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" "{{tenantName}}"

    Get pvComObject of hoJson to vJson
    Get ComPostJson3 Of hoHttp "https://domain.com/odata/Queues/UiPathODataSvc.AddQueueItem" "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://platform.uipath.com/odata/$metadata#queueItem/$entity",
    //   "QueueDefinitionId": 33196,
    //   "OutputData": null,
    //   "Status": "New",
    //   "ReviewStatus": "None",
    //   "ReviewerUserId": null,
    //   "Key": "7aa9a82d-781b-45e5-ba14-d1758825e314",
    //   "Reference": null,
    //   "ProcessingExceptionType": null,
    //   "DueDate": null,
    //   "Priority": "Normal",
    //   "DeferDate": null,
    //   "StartProcessing": null,
    //   "EndProcessing": null,
    //   "SecondsInPreviousAttempts": 0,
    //   "AncestorId": null,
    //   "RetryNumber": 0,
    //   "SpecificData": "{\"DynamicProperties\":{\"Type\":\"Customer\",\"Name\":\"Some Guy\"}}",
    //   "CreationTime": "2018-07-31T12:39:07.6923552Z",
    //   "Progress": null,
    //   "RowVersion": "AAAAAADu9Mg=",
    //   "Id": 3888968,
    //   "ProcessingException": null,
    //   "SpecificContent": {
    //     "Type": "Customer",
    //     "Name": "Some Guy"
    //   },
    //   "Output": null
    // }

    // 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
    Get ComIntOf Of hoJResp "QueueDefinitionId" To iQueueDefinitionId
    Get ComStringOf Of hoJResp "OutputData" To sOutputData
    Get ComStringOf Of hoJResp "Status" To sStatus
    Get ComStringOf Of hoJResp "ReviewStatus" To sReviewStatus
    Get ComStringOf Of hoJResp "ReviewerUserId" To sReviewerUserId
    Get ComStringOf Of hoJResp "Key" To sKey
    Get ComStringOf Of hoJResp "Reference" To sReference
    Get ComStringOf Of hoJResp "ProcessingExceptionType" To sProcessingExceptionType
    Get ComStringOf Of hoJResp "DueDate" To sDueDate
    Get ComStringOf Of hoJResp "Priority" To sPriority
    Get ComStringOf Of hoJResp "DeferDate" To sDeferDate
    Get ComStringOf Of hoJResp "StartProcessing" To sStartProcessing
    Get ComStringOf Of hoJResp "EndProcessing" To sEndProcessing
    Get ComIntOf Of hoJResp "SecondsInPreviousAttempts" To iSecondsInPreviousAttempts
    Get ComStringOf Of hoJResp "AncestorId" To sAncestorId
    Get ComIntOf Of hoJResp "RetryNumber" To iRetryNumber
    Get ComStringOf Of hoJResp "SpecificData" To sSpecificData
    Get ComStringOf Of hoJResp "CreationTime" To sCreationTime
    Get ComStringOf Of hoJResp "Progress" To sProgress
    Get ComStringOf Of hoJResp "RowVersion" To sRowVersion
    Get ComIntOf Of hoJResp "Id" To iId
    Get ComStringOf Of hoJResp "ProcessingException" To sProcessingException
    Get ComStringOf Of hoJResp "SpecificContent.Type" To sV_Type
    Get ComStringOf Of hoJResp "SpecificContent.Name" To sName
    Get ComStringOf Of hoJResp "Output" To sOutput


End_Procedure

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 '{
    "itemData": {
        "Name": "TestQueue",
        "Priority": "Normal",
        "SpecificContent": {
            "First": "Some String Value Here",
    		"First@odata.type": "#String",
            "Second": 516,
            "Fourth": "Did I skip the Third value?",
            "AnotherKey": true
        }
    }
}'
https://domain.com/odata/Queues/UiPathODataSvc.AddQueueItem

Postman Collection Item JSON

{
  "name": "Queue Items - Create",
  "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": "{\n    \"itemData\": {\n        \"Name\": \"TestQueue\",\n        \"Priority\": \"Normal\",\n        \"SpecificContent\": {\n            \"First\": \"Some String Value Here\",\n    \t\t\"First@odata.type\": \"#String\",\n            \"Second\": 516,\n            \"Fourth\": \"Did I skip the Third value?\",\n            \"AnotherKey\": true\n        }\n    }\n}"
    },
    "url": {
      "raw": "{{url}}/odata/Queues/UiPathODataSvc.AddQueueItem",
      "host": [
        "{{url}}"
      ],
      "path": [
        "odata",
        "Queues",
        "UiPathODataSvc.AddQueueItem"
      ]
    },
    "description": "Add an item to a Queue"
  },
  "response": [
    {
      "name": "Queue Items - Create",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"itemData\": {\n        \"Name\": \"TestQueue\",\n        \"Priority\": \"Normal\",\n        \"SpecificContent\": {\n            \"Type\": \"Customer\",\n    \t\t\"Name@odata.type\": \"#String\",\n            \"Name\": \"Some Guy\"\n        }\n    }\n}"
        },
        "url": {
          "raw": "{{url}}/odata/Queues/UiPathODataSvc.AddQueueItem",
          "host": [
            "{{url}}"
          ],
          "path": [
            "odata",
            "Queues",
            "UiPathODataSvc.AddQueueItem"
          ]
        }
      },
      "status": "Created",
      "code": 201,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "CF-RAY",
          "value": "44302040491791fa-EWR",
          "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": "725",
          "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": "Tue, 31 Jul 2018 12:39:07 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": "Location",
          "value": "https://platform.uipath.com/odata/queueItem(3888968)",
          "name": "Location",
          "description": "Used in redirection, or when a new resource has been created."
        },
        {
          "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": "{\"@odata.context\":\"https://platform.uipath.com/odata/$metadata#queueItem/$entity\",\"QueueDefinitionId\":33196,\"OutputData\":null,\"Status\":\"New\",\"ReviewStatus\":\"None\",\"ReviewerUserId\":null,\"Key\":\"7aa9a82d-781b-45e5-ba14-d1758825e314\",\"Reference\":null,\"ProcessingExceptionType\":null,\"DueDate\":null,\"Priority\":\"Normal\",\"DeferDate\":null,\"StartProcessing\":null,\"EndProcessing\":null,\"SecondsInPreviousAttempts\":0,\"AncestorId\":null,\"RetryNumber\":0,\"SpecificData\":\"{\\\"DynamicProperties\\\":{\\\"Type\\\":\\\"Customer\\\",\\\"Name\\\":\\\"Some Guy\\\"}}\",\"CreationTime\":\"2018-07-31T12:39:07.6923552Z\",\"Progress\":null,\"RowVersion\":\"AAAAAADu9Mg=\",\"Id\":3888968,\"ProcessingException\":null,\"SpecificContent\":{\"Type\":\"Customer\",\"Name\":\"Some Guy\"},\"Output\":null}"
    }
  ]
}