Chilkat Online Tools

unicodeC / ForgeRock Identity Cloud Collection / Query All Managed Identities

Back to Collection Items

#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>

void ChilkatSample(void)
    {
    HCkHttpW http;
    BOOL success;
    HCkJsonObjectW queryParams;
    HCkHttpResponseW resp;

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

    http = CkHttpW_Create();

    queryParams = CkJsonObjectW_Create();
    CkJsonObjectW_UpdateString(queryParams,L"_fields",L"userName,givenName,sn,mail,accountStatus");
    CkJsonObjectW_UpdateString(queryParams,L"_prettyPrint",L"true");
    CkJsonObjectW_UpdateString(queryParams,L"_queryFilter",L"true");

    CkHttpW_SetRequestHeader(http,L"Accept-API-Version",L"resource=1.0");
    // Adds the "Authorization: Bearer <access_token>" header.
    CkHttpW_putAuthToken(http,L"<access_token>");
    CkHttpW_SetRequestHeader(http,L"{{cookieName}}",L"{{adminSSOToken}}");

    resp = CkHttpW_QuickRequestParams(http,L"GET",L"https://<tenant-name>.forgeblocks.com/openidm/managed/alpha_user",queryParams);
    if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(queryParams);
        return;
    }

    wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
    wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
    CkHttpResponseW_Dispose(resp);


    CkHttpW_Dispose(http);
    CkJsonObjectW_Dispose(queryParams);

    }

Curl Command

curl -G -d "_fields=userName,givenName,sn,mail,accountStatus"
	-d "_prettyPrint=true"
	-d "_queryFilter=true"
	-H "Authorization: Bearer <access_token>"
	-H "Accept-API-Version: resource=1.0"
	-H "{{cookieName}}: {{adminSSOToken}}"
https://<tenant-name>.forgeblocks.com/openidm/managed/alpha_user

Postman Collection Item JSON

{
  "name": "Query All Managed Identities",
  "event": [
    {
      "listen": "test",
      "script": {
        "exec": [
          "const JSONResponse = JSON.parse(responseBody);",
          "",
          "// Did request contain results?",
          "if(JSONResponse.resultCount && JSONResponse.resultCount > 0)",
          "{",
          "  // Set `managedUserId` variable",
          "  pm.globals.set(\"managedUserId\", JSONResponse.result[0]._id);",
          "}",
          "else",
          "{",
          "  pm.globals.set(\"managedUserId\", \"none_found\");  ",
          "}"
        ],
        "type": "text/javascript"
      }
    }
  ],
  "request": {
    "method": "GET",
    "header": [
      {
        "description": "(Required) ",
        "key": "Accept-API-Version",
        "value": "resource=1.0",
        "disabled": true
      },
      {
        "key": "{{cookieName}}",
        "value": "{{adminSSOToken}}",
        "type": "text"
      }
    ],
    "url": {
      "raw": "{{platformUrl}}/openidm/managed/alpha_user?_fields=userName,givenName,sn,mail,accountStatus&_prettyPrint=true&_queryFilter=true",
      "host": [
        "{{platformUrl}}"
      ],
      "path": [
        "openidm",
        "managed",
        "alpha_user"
      ],
      "query": [
        {
          "key": "_fields",
          "value": "userName,givenName,sn,mail,accountStatus",
          "description": "Optional parameter containing a comma separated list of field references specifying which fields of the targeted JSON resource should be returned."
        },
        {
          "key": "_prettyPrint",
          "value": "true",
          "description": "Optional parameter requesting that the returned JSON resource content should be formatted to be more human readable."
        },
        {
          "key": "_queryFilter",
          "value": "true"
        }
      ]
    }
  },
  "response": [
    {
      "name": "Success",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "(Required) ",
            "key": "Accept-API-Version",
            "value": "<string>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/openidm/managed/user#1.0_query_filter?_fields=&_prettyPrint=true&_queryFilter=<string>&_pageSize=<integer>&_totalPagedResultsPolicy=<string>&_sortKeys=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "openidm",
            "managed",
            "user"
          ],
          "hash": "1.0_query_filter?_fields=&_prettyPrint=true&_queryFilter=<string>&_pageSize=<integer>&_totalPagedResultsPolicy=<string>&_sortKeys=<string>"
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "*/*"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}