Chilkat Online Tools

PowerBuilder / Orchestrator API Documentation / GET Folders

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_QueryParams
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Key
string ls_DisplayName
string ls_FullyQualifiedName
string ls_FullyQualifiedNameOrderable
string ls_Description
string ls_ProvisionType
string ls_PermissionModel
string ls_ParentId
string ls_ParentKey
integer li_IsActive
string ls_FeedType
integer li_Id
string ls_Odata_context
integer li_Odata_count
integer i
integer li_Count_i

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

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_QueryParams = create oleobject
li_rc = loo_QueryParams.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_QueryParams.UpdateString("$Filter","DisplayName eq 'UnattendedProcesses'")

// Adds the "Authorization: Bearer <access_token>" header.
loo_Http.AuthToken = "<access_token>"

loo_Resp = loo_Http.QuickRequestParams("GET","https://domain.com/orchestrator_/odata/folders",loo_QueryParams)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_QueryParams
    return
end if

loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

loo_Resp.GetBodySb(loo_SbResponseBody)

loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Resp.Header
    Write-Debug "Failed."
    destroy loo_Resp
    destroy loo_Http
    destroy loo_QueryParams
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

destroy loo_Resp

// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)

// {
//   "@odata.context": "https://cloud.uipath.com/robertorg/modernDepartment/orchestrator_/odata/$metadata#Folders",
//   "@odata.count": 1,
//   "value": [
//     {
//       "Key": "0d521387-6fb2-4055-a22c-62b7225565b4",
//       "DisplayName": "UnattendedProcesses",
//       "FullyQualifiedName": "UnattendedProcesses",
//       "FullyQualifiedNameOrderable": "UnattendedProcesses",
//       "Description": null,
//       "ProvisionType": "Automatic",
//       "PermissionModel": "FineGrained",
//       "ParentId": null,
//       "ParentKey": null,
//       "IsActive": true,
//       "FeedType": "Processes",
//       "Id": 515128
//     }
//   ]
// }

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

ls_Odata_context = loo_JResp.StringOf("~"@odata.context~"")
li_Odata_count = loo_JResp.IntOf("~"@odata.count~"")
i = 0
li_Count_i = loo_JResp.SizeOfArray("value")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Key = loo_JResp.StringOf("value[i].Key")
    ls_DisplayName = loo_JResp.StringOf("value[i].DisplayName")
    ls_FullyQualifiedName = loo_JResp.StringOf("value[i].FullyQualifiedName")
    ls_FullyQualifiedNameOrderable = loo_JResp.StringOf("value[i].FullyQualifiedNameOrderable")
    ls_Description = loo_JResp.StringOf("value[i].Description")
    ls_ProvisionType = loo_JResp.StringOf("value[i].ProvisionType")
    ls_PermissionModel = loo_JResp.StringOf("value[i].PermissionModel")
    ls_ParentId = loo_JResp.StringOf("value[i].ParentId")
    ls_ParentKey = loo_JResp.StringOf("value[i].ParentKey")
    li_IsActive = loo_JResp.BoolOf("value[i].IsActive")
    ls_FeedType = loo_JResp.StringOf("value[i].FeedType")
    li_Id = loo_JResp.IntOf("value[i].Id")
    i = i + 1
loop


destroy loo_Http
destroy loo_QueryParams
destroy loo_SbResponseBody
destroy loo_JResp

Curl Command

curl -G -d "$Filter=DisplayName%20eq%20%27UnattendedProcesses%27"
	-H "Authorization: Bearer <access_token>"
https://domain.com/orchestrator_/odata/folders

Postman Collection Item JSON

{
  "name": "GET Folders",
  "event": [
    {
      "listen": "test",
      "script": {
        "exec": [
          "//set folder ID\r",
          "var myResponse = pm.response.json();\r",
          "pm.collectionVariables.set(\"folderId\", myResponse.value[0].Id);\r",
          "console.log(pm.collectionVariables.get(\"folderId\"));\r",
          "\r",
          "//test status code\r",
          "pm.test(\"Status code is 200\", function () {\r",
          "    pm.response.to.have.status(200);\r",
          "});"
        ],
        "type": "text/javascript"
      }
    }
  ],
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{url}}/orchestrator_/odata/folders?$Filter=DisplayName eq 'UnattendedProcesses'",
      "host": [
        "{{url}}"
      ],
      "path": [
        "orchestrator_",
        "odata",
        "folders"
      ],
      "query": [
        {
          "key": "$Filter",
          "value": "DisplayName eq 'UnattendedProcesses'"
        }
      ]
    }
  },
  "response": [
    {
      "name": "Test",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{url}}/orchestrator_/odata/folders?$Filter=DisplayName eq 'UnattendedProcesses'",
          "host": [
            "{{url}}"
          ],
          "path": [
            "orchestrator_",
            "odata",
            "folders"
          ],
          "query": [
            {
              "key": "$Filter",
              "value": "DisplayName eq 'UnattendedProcesses'"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Date",
          "value": "Thu, 29 Apr 2021 07:07:26 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": "Vary",
          "value": "Accept-Encoding"
        },
        {
          "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": "b3389aa9-ce79-4516-8a18-88aaa1d750f2"
        },
        {
          "key": "OData-Version",
          "value": "4.0"
        },
        {
          "key": "api-supported-versions",
          "value": "12.0"
        },
        {
          "key": "CF-Cache-Status",
          "value": "DYNAMIC"
        },
        {
          "key": "cf-request-id",
          "value": "09be0d432000000d6ba1821000000001"
        },
        {
          "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": "6476b17e9f840d6b-VIE"
        },
        {
          "key": "Content-Encoding",
          "value": "br"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"@odata.context\": \"https://cloud.uipath.com/robertorg/modernDepartment/orchestrator_/odata/$metadata#Folders\",\n    \"@odata.count\": 1,\n    \"value\": [\n        {\n            \"Key\": \"0d521387-6fb2-4055-a22c-62b7225565b4\",\n            \"DisplayName\": \"UnattendedProcesses\",\n            \"FullyQualifiedName\": \"UnattendedProcesses\",\n            \"FullyQualifiedNameOrderable\": \"UnattendedProcesses\",\n            \"Description\": null,\n            \"ProvisionType\": \"Automatic\",\n            \"PermissionModel\": \"FineGrained\",\n            \"ParentId\": null,\n            \"ParentKey\": null,\n            \"IsActive\": true,\n            \"FeedType\": \"Processes\",\n            \"Id\": 515128\n        }\n    ]\n}"
    }
  ]
}