Chilkat Online Tools

PowerBuilder / Atlassian Confluence Cloud / Get group memberships for user

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_QueryParams
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_V_type
string ls_Name
string ls_Id
integer li_Start
integer li_Limit
integer li_Size
integer i
integer li_Count_i

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

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_QueryParams = create oleobject
li_rc = loo_QueryParams.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_QueryParams.UpdateString("key","<string>")
loo_QueryParams.UpdateString("username","<string>")
loo_QueryParams.UpdateString("accountId","<string>")
loo_QueryParams.UpdateInt("start",0)
loo_QueryParams.UpdateInt("limit",200)

// Adds the "Authorization: Bearer <access_token>" header.
loo_Http.AuthToken = "<access_token>"

loo_Resp = loo_Http.QuickRequestParams("GET","https://your-domain.atlassian.net/wiki/rest/api/user/memberof",loo_QueryParams)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_QueryParams
    return
end if

loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

loo_Resp.GetBodySb(loo_SbResponseBody)

loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Resp.Header
    Write-Debug "Failed."
    destroy loo_Resp
    destroy loo_Http
    destroy loo_QueryParams
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

destroy loo_Resp

// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)

// {
//   "results": [
//     {
//       "type": "group",
//       "name": "consequat amet ",
//       "id": "Ut",
//       "_links": {}
//     },
//     {
//       "type": "group",
//       "name": "qui eu",
//       "id": "consequat quis occaecat proident voluptate",
//       "_links": {}
//     }
//   ],
//   "start": -67251213,
//   "limit": 46114380,
//   "size": -50386405
// }

// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

li_Start = loo_JResp.IntOf("start")
li_Limit = loo_JResp.IntOf("limit")
li_Size = loo_JResp.IntOf("size")
i = 0
li_Count_i = loo_JResp.SizeOfArray("results")
do while i < li_Count_i
    loo_JResp.I = i
    ls_V_type = loo_JResp.StringOf("results[i].type")
    ls_Name = loo_JResp.StringOf("results[i].name")
    ls_Id = loo_JResp.StringOf("results[i].id")
    i = i + 1
loop


destroy loo_Http
destroy loo_QueryParams
destroy loo_SbResponseBody
destroy loo_JResp

Curl Command

curl -G -d "key=%3Cstring%3E"
	-d "username=%3Cstring%3E"
	-d "accountId=%3Cstring%3E"
	-d "start=0"
	-d "limit=200"
	-H "Authorization: Bearer <access_token>"
https://your-domain.atlassian.net/wiki/rest/api/user/memberof

Postman Collection Item JSON

{
  "name": "Get group memberships for user",
  "request": {
    "auth": {
      "type": "oauth2"
    },
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/api/user/memberof?key=<string>&username=<string>&accountId=<string>&start=0&limit=200",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "user",
        "memberof"
      ],
      "query": [
        {
          "key": "key",
          "value": "<string>",
          "description": "This parameter is no longer available and will be removed from the documentation soon.\nUse `accountId` instead.\nSee the [deprecation notice](/cloud/confluence/deprecation-notice-user-privacy-api-migration-guide/) for details."
        },
        {
          "key": "username",
          "value": "<string>",
          "description": "This parameter is no longer available and will be removed from the documentation soon.\nUse `accountId` instead.\nSee the [deprecation notice](/cloud/confluence/deprecation-notice-user-privacy-api-migration-guide/) for details."
        },
        {
          "key": "accountId",
          "value": "<string>",
          "description": "(Required) The account ID of the user, which uniquely identifies the user across all Atlassian products.\nFor example, `384093:32b4d9w0-f6a5-3535-11a3-9c8c88d10192`."
        },
        {
          "key": "start",
          "value": "0",
          "description": "The starting index of the returned groups."
        },
        {
          "key": "limit",
          "value": "200",
          "description": "The maximum number of groups to return per page.\nNote, this may be restricted by fixed system limits."
        }
      ]
    },
    "description": "Returns the groups that a user is a member of.\n\n**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:\nPermission to access the Confluence site ('Can use' global permission)."
  },
  "response": [
    {
      "name": "Returned if the requested groups are returned.",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: oauth2",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/user/memberof?key=<string>&username=<string>&accountId=<string>&start=0&limit=200",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "user",
            "memberof"
          ],
          "query": [
            {
              "key": "key",
              "value": "<string>"
            },
            {
              "key": "username",
              "value": "<string>"
            },
            {
              "key": "accountId",
              "value": "<string>"
            },
            {
              "key": "start",
              "value": "0"
            },
            {
              "key": "limit",
              "value": "200"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"results\": [\n  {\n   \"type\": \"group\",\n   \"name\": \"consequat amet \",\n   \"id\": \"Ut\",\n   \"_links\": {}\n  },\n  {\n   \"type\": \"group\",\n   \"name\": \"qui eu\",\n   \"id\": \"consequat quis occaecat proident voluptate\",\n   \"_links\": {}\n  }\n ],\n \"start\": -67251213,\n \"limit\": 46114380,\n \"size\": -50386405\n}"
    },
    {
      "name": "Returned if the calling user does not have permission to use\nConfluence.",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: oauth2",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/user/memberof?key=<string>&username=<string>&accountId=<string>&start=0&limit=200",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "user",
            "memberof"
          ],
          "query": [
            {
              "key": "key",
              "value": "<string>"
            },
            {
              "key": "username",
              "value": "<string>"
            },
            {
              "key": "accountId",
              "value": "<string>"
            },
            {
              "key": "start",
              "value": "0"
            },
            {
              "key": "limit",
              "value": "200"
            }
          ]
        }
      },
      "status": "Forbidden",
      "code": 403,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}