Chilkat Online Tools

Ruby / ForgeRock Identity Cloud Collection / Query All Managed Identities

Back to Collection Items

require 'chilkat'

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

http = Chilkat::CkHttp.new()

queryParams = Chilkat::CkJsonObject.new()
queryParams.UpdateString("_fields","userName,givenName,sn,mail,accountStatus")
queryParams.UpdateString("_prettyPrint","true")
queryParams.UpdateString("_queryFilter","true")

http.SetRequestHeader("Accept-API-Version","resource=1.0")
# Adds the "Authorization: Bearer <access_token>" header.
http.put_AuthToken("<access_token>")
http.SetRequestHeader("{{cookieName}}","{{adminSSOToken}}")

# resp is a CkHttpResponse
resp = http.QuickRequestParams("GET","https://<tenant-name>.forgeblocks.com/openidm/managed/alpha_user",queryParams)
if (http.get_LastMethodSuccess() == false)
    print http.lastErrorText() + "\n";
    exit
end

print resp.get_StatusCode().to_s() + "\n";
print resp.bodyStr() + "\n";

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": ""
    }
  ]
}