Chilkat Online Tools

unicodeC / ForgeRock Identity Cloud Collection / Step 2: Get a Managed Identity

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"_queryFilter",L"userName eq \"{{managedUsername}}\"");

    CkHttpW_SetRequestHeader(http,L"X-OpenIDM-Username",L"{{adminUsername}}");
    CkHttpW_SetRequestHeader(http,L"Accept-API-Version",L"resource=1.0");
    CkHttpW_SetRequestHeader(http,L"X-OpenIDM-Password",L"{{adminPassword}}");
    // Adds the "Authorization: Bearer <access_token>" header.
    CkHttpW_putAuthToken(http,L"<access_token>");

    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 "_queryFilter=userName%20eq%20%22%7B%7BmanagedUsername%7D%7D%22"
	-H "Authorization: Bearer <access_token>"
	-H "Accept-API-Version: resource=1.0"
	-H "X-OpenIDM-Username: {{adminUsername}}"
	-H "X-OpenIDM-Password: {{adminPassword}}"
https://<tenant-name>.forgeblocks.com/openidm/managed/alpha_user

Postman Collection Item JSON

{
  "name": "Step 2: Get a Managed Identity",
  "event": [
    {
      "listen": "test",
      "script": {
        "exec": [
          "const jsonData = JSON.parse(responseBody);",
          "if(jsonData._id && jsonData._id != \"\"){",
          "    pm.globals.set(\"managedUserId\", jsonData._id);",
          "}",
          ""
        ],
        "type": "text/javascript"
      }
    }
  ],
  "request": {
    "method": "GET",
    "header": [
      {
        "description": "(Required) ",
        "key": "Accept-API-Version",
        "value": "resource=1.0",
        "disabled": true
      },
      {
        "key": "X-OpenIDM-Username",
        "type": "text",
        "value": "{{adminUsername}}",
        "disabled": true
      },
      {
        "key": "X-OpenIDM-Password",
        "type": "text",
        "value": "{{adminPassword}}",
        "disabled": true
      }
    ],
    "url": {
      "raw": "{{platformUrl}}/openidm/managed/alpha_user?_queryFilter=userName eq \"{{managedUsername}}\"",
      "host": [
        "{{platformUrl}}"
      ],
      "path": [
        "openidm",
        "managed",
        "alpha_user"
      ],
      "query": [
        {
          "key": "_fields",
          "value": "",
          "description": "Optional parameter containing a comma separated list of field references specifying which fields of the targeted JSON resource should be returned.",
          "disabled": true
        },
        {
          "key": "_queryFilter",
          "value": "userName eq \"{{managedUsername}}\""
        }
      ]
    },
    "description": "Obtain the details of a managed identity."
  },
  "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": ""
    }
  ]
}