Chilkat Online Tools

Swift / ForgeRock Identity Cloud Collection / Query All Managed Identities

Back to Collection Items

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

    let http = CkoHttp()
    var success: Bool

    let queryParams = CkoJsonObject()
    queryParams.UpdateString("_fields", value: "userName,givenName,sn,mail,accountStatus")
    queryParams.UpdateString("_prettyPrint", value: "true")
    queryParams.UpdateString("_queryFilter", value: "true")

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

    var resp: CkoHttpResponse? = http.QuickRequestParams("GET", url: "https://<tenant-name>.forgeblocks.com/openidm/managed/alpha_user", json: queryParams)
    if http.LastMethodSuccess == false {
        print("\(http.LastErrorText)")
        return
    }

    print("\(resp!.StatusCode.intValue)")
    print("\(resp!.BodyStr)")
    resp = nil

}

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