Chilkat Online Tools

autoit / ForgeRock Identity Cloud Collection / Query All Managed Identities

Back to Collection Items

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

$oHttp = ObjCreate("Chilkat.Http")
Local $bSuccess

$oQueryParams = ObjCreate("Chilkat.JsonObject")
$oQueryParams.UpdateString("_fields","userName,givenName,sn,mail,accountStatus")
$oQueryParams.UpdateString("_prettyPrint","true")
$oQueryParams.UpdateString("_queryFilter","true")

$oHttp.SetRequestHeader "Accept-API-Version","resource=1.0"
; Adds the "Authorization: Bearer <access_token>" header.
$oHttp.AuthToken = "<access_token>"
$oHttp.SetRequestHeader "{{cookieName}}","{{adminSSOToken}}"

Local $oResp = $oHttp.QuickRequestParams("GET","https://<tenant-name>.forgeblocks.com/openidm/managed/alpha_user",$oQueryParams)
If ($oHttp.LastMethodSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

ConsoleWrite($oResp.StatusCode & @CRLF)
ConsoleWrite($oResp.BodyStr & @CRLF)

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