Chilkat Online Tools

C / Orchestrator / Assets - Get all + Per Robot Values

Back to Collection Items

#include <C_CkHttp.h>
#include <C_CkJsonObject.h>
#include <C_CkHttpResponse.h>
#include <C_CkStringBuilder.h>

void ChilkatSample(void)
    {
    HCkHttp http;
    BOOL success;
    HCkJsonObject queryParams;
    HCkHttpResponse resp;
    HCkStringBuilder sbResponseBody;
    HCkJsonObject jResp;
    int respStatusCode;
    const char *Name;
    BOOL CanBeDeleted;
    const char *ValueScope;
    const char *ValueType;
    const char *Value;
    const char *StringValue;
    BOOL BoolValue;
    int IntValue;
    const char *CredentialUsername;
    const char *CredentialPassword;
    const char *ExternalName;
    const char *CredentialStoreId;
    BOOL HasDefaultValue;
    const char *Description;
    int Id;
    int j;
    int count_j;
    int RobotId;
    const char *RobotName;
    const char *KeyTrail;
    int k;
    int count_k;
    const char *odata_context;
    int odata_count;
    int i;
    int count_i;

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

    http = CkHttp_Create();

    queryParams = CkJsonObject_Create();
    CkJsonObject_UpdateString(queryParams,"$expand","RobotValues");

    CkHttp_SetRequestHeader(http,"Content-Type","application/json");
    // Adds the "Authorization: Bearer <access_token>" header.
    CkHttp_putAuthToken(http,"<access_token>");
    CkHttp_SetRequestHeader(http,"X-UIPATH-OrganizationUnitId","{{folderId}}");
    CkHttp_SetRequestHeader(http,"X-UIPATH-TenantName","{{tenantName}}");

    resp = CkHttp_QuickRequestParams(http,"GET","https://domain.com/odata/Assets",queryParams);
    if (CkHttp_getLastMethodSuccess(http) == FALSE) {
        printf("%s\n",CkHttp_lastErrorText(http));
        CkHttp_Dispose(http);
        CkJsonObject_Dispose(queryParams);
        return;
    }

    sbResponseBody = CkStringBuilder_Create();
    CkHttpResponse_GetBodySb(resp,sbResponseBody);

    jResp = CkJsonObject_Create();
    CkJsonObject_LoadSb(jResp,sbResponseBody);
    CkJsonObject_putEmitCompact(jResp,FALSE);

    printf("Response Body:\n");
    printf("%s\n",CkJsonObject_emit(jResp));

    respStatusCode = CkHttpResponse_getStatusCode(resp);
    printf("Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        printf("Response Header:\n");
        printf("%s\n",CkHttpResponse_header(resp));
        printf("Failed.\n");
        CkHttpResponse_Dispose(resp);
        CkHttp_Dispose(http);
        CkJsonObject_Dispose(queryParams);
        CkStringBuilder_Dispose(sbResponseBody);
        CkJsonObject_Dispose(jResp);
        return;
    }

    CkHttpResponse_Dispose(resp);

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

    // {
    //   "@odata.context": "https://platform.uipath.com/deanmauro/dean/odata/$metadata#Assets",
    //   "@odata.count": 2,
    //   "value": [
    //     {
    //       "Name": "Asset 2",
    //       "CanBeDeleted": true,
    //       "ValueScope": "Global",
    //       "ValueType": "Text",
    //       "Value": "I would not, Cassius, yet I love him well.",
    //       "StringValue": "I would not, Cassius, yet I love him well.",
    //       "BoolValue": false,
    //       "IntValue": 0,
    //       "CredentialUsername": "",
    //       "CredentialPassword": "",
    //       "ExternalName": "",
    //       "CredentialStoreId": null,
    //       "HasDefaultValue": true,
    //       "Description": null,
    //       "Id": 8588,
    //       "KeyValueList": [
    //       ],
    //       "RobotValues": [
    //       ]
    //     },
    //     {
    //       "Name": "blah",
    //       "CanBeDeleted": true,
    //       "ValueScope": "PerRobot",
    //       "ValueType": "Integer",
    //       "Value": null,
    //       "StringValue": "",
    //       "BoolValue": false,
    //       "IntValue": 0,
    //       "CredentialUsername": "",
    //       "CredentialPassword": "",
    //       "ExternalName": "",
    //       "CredentialStoreId": null,
    //       "HasDefaultValue": false,
    //       "Description": null,
    //       "Id": 23656,
    //       "KeyValueList": [
    //       ],
    //       "RobotValues": [
    //         {
    //           "RobotId": 33530,
    //           "RobotName": "joe",
    //           "KeyTrail": "***4ef589a",
    //           "ValueType": "Integer",
    //           "StringValue": "",
    //           "BoolValue": false,
    //           "IntValue": 1,
    //           "Value": "1",
    //           "CredentialUsername": "",
    //           "CredentialPassword": "",
    //           "ExternalName": "",
    //           "CredentialStoreId": null,
    //           "Id": 199104,
    //           "KeyValueList": [
    //           ]
    //         },
    //         {
    //           "RobotId": 42307,
    //           "RobotName": "jose",
    //           "KeyTrail": "***88bvb04",
    //           "ValueType": "Integer",
    //           "StringValue": "",
    //           "BoolValue": false,
    //           "IntValue": 2,
    //           "Value": "2",
    //           "CredentialUsername": "",
    //           "CredentialPassword": "",
    //           "ExternalName": "",
    //           "CredentialStoreId": null,
    //           "Id": 199105,
    //           "KeyValueList": [
    //           ]
    //         }
    //       ]
    //     }
    //   ]
    // }

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

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.

    odata_context = CkJsonObject_stringOf(jResp,"\"@odata.context\"");
    odata_count = CkJsonObject_IntOf(jResp,"\"@odata.count\"");
    i = 0;
    count_i = CkJsonObject_SizeOfArray(jResp,"value");
    while (i < count_i) {
        CkJsonObject_putI(jResp,i);
        Name = CkJsonObject_stringOf(jResp,"value[i].Name");
        CanBeDeleted = CkJsonObject_BoolOf(jResp,"value[i].CanBeDeleted");
        ValueScope = CkJsonObject_stringOf(jResp,"value[i].ValueScope");
        ValueType = CkJsonObject_stringOf(jResp,"value[i].ValueType");
        Value = CkJsonObject_stringOf(jResp,"value[i].Value");
        StringValue = CkJsonObject_stringOf(jResp,"value[i].StringValue");
        BoolValue = CkJsonObject_BoolOf(jResp,"value[i].BoolValue");
        IntValue = CkJsonObject_IntOf(jResp,"value[i].IntValue");
        CredentialUsername = CkJsonObject_stringOf(jResp,"value[i].CredentialUsername");
        CredentialPassword = CkJsonObject_stringOf(jResp,"value[i].CredentialPassword");
        ExternalName = CkJsonObject_stringOf(jResp,"value[i].ExternalName");
        CredentialStoreId = CkJsonObject_stringOf(jResp,"value[i].CredentialStoreId");
        HasDefaultValue = CkJsonObject_BoolOf(jResp,"value[i].HasDefaultValue");
        Description = CkJsonObject_stringOf(jResp,"value[i].Description");
        Id = CkJsonObject_IntOf(jResp,"value[i].Id");
        j = 0;
        count_j = CkJsonObject_SizeOfArray(jResp,"value[i].KeyValueList");
        while (j < count_j) {
            CkJsonObject_putJ(jResp,j);
            j = j + 1;
        }

        j = 0;
        count_j = CkJsonObject_SizeOfArray(jResp,"value[i].RobotValues");
        while (j < count_j) {
            CkJsonObject_putJ(jResp,j);
            RobotId = CkJsonObject_IntOf(jResp,"value[i].RobotValues[j].RobotId");
            RobotName = CkJsonObject_stringOf(jResp,"value[i].RobotValues[j].RobotName");
            KeyTrail = CkJsonObject_stringOf(jResp,"value[i].RobotValues[j].KeyTrail");
            ValueType = CkJsonObject_stringOf(jResp,"value[i].RobotValues[j].ValueType");
            StringValue = CkJsonObject_stringOf(jResp,"value[i].RobotValues[j].StringValue");
            BoolValue = CkJsonObject_BoolOf(jResp,"value[i].RobotValues[j].BoolValue");
            IntValue = CkJsonObject_IntOf(jResp,"value[i].RobotValues[j].IntValue");
            Value = CkJsonObject_stringOf(jResp,"value[i].RobotValues[j].Value");
            CredentialUsername = CkJsonObject_stringOf(jResp,"value[i].RobotValues[j].CredentialUsername");
            CredentialPassword = CkJsonObject_stringOf(jResp,"value[i].RobotValues[j].CredentialPassword");
            ExternalName = CkJsonObject_stringOf(jResp,"value[i].RobotValues[j].ExternalName");
            CredentialStoreId = CkJsonObject_stringOf(jResp,"value[i].RobotValues[j].CredentialStoreId");
            Id = CkJsonObject_IntOf(jResp,"value[i].RobotValues[j].Id");
            k = 0;
            count_k = CkJsonObject_SizeOfArray(jResp,"value[i].RobotValues[j].KeyValueList");
            while (k < count_k) {
                CkJsonObject_putK(jResp,k);
                k = k + 1;
            }

            j = j + 1;
        }

        i = i + 1;
    }



    CkHttp_Dispose(http);
    CkJsonObject_Dispose(queryParams);
    CkStringBuilder_Dispose(sbResponseBody);
    CkJsonObject_Dispose(jResp);

    }

Curl Command

curl -G -d "$expand=RobotValues"
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: application/json"
	-H "X-UIPATH-TenantName: {{tenantName}}"
	-H "X-UIPATH-OrganizationUnitId: {{folderId}}"
https://domain.com/odata/Assets

Postman Collection Item JSON

{
  "name": "Assets - Get all + Per Robot Values",
  "event": [
    {
      "listen": "test",
      "script": {
        "exec": [
          ""
        ],
        "type": "text/javascript"
      }
    }
  ],
  "request": {
    "method": "GET",
    "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"
      }
    ],
    "url": {
      "raw": "{{url}}/odata/Assets?$expand=RobotValues",
      "host": [
        "{{url}}"
      ],
      "path": [
        "odata",
        "Assets"
      ],
      "query": [
        {
          "key": "$expand",
          "value": "RobotValues"
        }
      ]
    },
    "description": "Get all Assets and display Per Robot values in the response. For global Assets, this call provides no extra features."
  },
  "response": [
    {
      "name": "Assets - Get all (Including Per Robot Values)",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{url}}/odata/Assets?$expand=RobotValues",
          "host": [
            "{{url}}"
          ],
          "path": [
            "odata",
            "Assets"
          ],
          "query": [
            {
              "key": "$expand",
              "value": "RobotValues"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "CF-RAY",
          "value": "443012f809dd91fa-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-Encoding",
          "value": "gzip",
          "name": "Content-Encoding",
          "description": "The type of encoding used on the data."
        },
        {
          "key": "Content-Length",
          "value": "588",
          "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:30:03 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": "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": "Vary",
          "value": "Accept-Encoding",
          "name": "Vary",
          "description": "Tells downstream proxies how to match future request headers to decide whether the cached response can be used rather than requesting a fresh one from the origin server."
        },
        {
          "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": "{\r\n    \"@odata.context\": \"https://platform.uipath.com/deanmauro/dean/odata/$metadata#Assets\",\r\n    \"@odata.count\": 2,\r\n    \"value\": [\r\n        {\r\n            \"Name\": \"Asset 2\",\r\n            \"CanBeDeleted\": true,\r\n            \"ValueScope\": \"Global\",\r\n            \"ValueType\": \"Text\",\r\n            \"Value\": \"I would not, Cassius, yet I love him well.\",\r\n            \"StringValue\": \"I would not, Cassius, yet I love him well.\",\r\n            \"BoolValue\": false,\r\n            \"IntValue\": 0,\r\n            \"CredentialUsername\": \"\",\r\n            \"CredentialPassword\": \"\",\r\n            \"ExternalName\": \"\",\r\n            \"CredentialStoreId\": null,\r\n            \"HasDefaultValue\": true,\r\n            \"Description\": null,\r\n            \"Id\": 8588,\r\n            \"KeyValueList\": [],\r\n            \"RobotValues\": []\r\n        },\r\n        {\r\n            \"Name\": \"blah\",\r\n            \"CanBeDeleted\": true,\r\n            \"ValueScope\": \"PerRobot\",\r\n            \"ValueType\": \"Integer\",\r\n            \"Value\": null,\r\n            \"StringValue\": \"\",\r\n            \"BoolValue\": false,\r\n            \"IntValue\": 0,\r\n            \"CredentialUsername\": \"\",\r\n            \"CredentialPassword\": \"\",\r\n            \"ExternalName\": \"\",\r\n            \"CredentialStoreId\": null,\r\n            \"HasDefaultValue\": false,\r\n            \"Description\": null,\r\n            \"Id\": 23656,\r\n            \"KeyValueList\": [],\r\n            \"RobotValues\": [\r\n                {\r\n                    \"RobotId\": 33530,\r\n                    \"RobotName\": \"joe\",\r\n                    \"KeyTrail\": \"***4ef589a\",\r\n                    \"ValueType\": \"Integer\",\r\n                    \"StringValue\": \"\",\r\n                    \"BoolValue\": false,\r\n                    \"IntValue\": 1,\r\n                    \"Value\": \"1\",\r\n                    \"CredentialUsername\": \"\",\r\n                    \"CredentialPassword\": \"\",\r\n                    \"ExternalName\": \"\",\r\n                    \"CredentialStoreId\": null,\r\n                    \"Id\": 199104,\r\n                    \"KeyValueList\": []\r\n                },\r\n                {\r\n                    \"RobotId\": 42307,\r\n                    \"RobotName\": \"jose\",\r\n                    \"KeyTrail\": \"***88bvb04\",\r\n                    \"ValueType\": \"Integer\",\r\n                    \"StringValue\": \"\",\r\n                    \"BoolValue\": false,\r\n                    \"IntValue\": 2,\r\n                    \"Value\": \"2\",\r\n                    \"CredentialUsername\": \"\",\r\n                    \"CredentialPassword\": \"\",\r\n                    \"ExternalName\": \"\",\r\n                    \"CredentialStoreId\": null,\r\n                    \"Id\": 199105,\r\n                    \"KeyValueList\": []\r\n                }\r\n            ]\r\n        }\r\n    ]\r\n}"
    }
  ]
}