Chilkat Online Tools

PowerBuilder / Atlassian Confluence Cloud / Get anonymous 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_Operation
string ls_TargetType
string ls_V_type
string ls_Path
integer li_Width
integer li_Height
integer li_IsDefault
string ls_DisplayName
string ls_Operations
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("expand","<string>")
loo_QueryParams.UpdateString("expand","<string>")

// 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/anonymous",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)

// {
//   "type": "non ut",
//   "profilePicture": {
//     "path": "id pariatur occaecat cillum",
//     "width": 98006898,
//     "height": 65551585,
//     "isDefault": true
//   },
//   "displayName": "eiusmod",
//   "_expandable": {
//     "operations": "Duis"
//   },
//   "_links": {},
//   "operations": [
//     {
//       "operation": "purge",
//       "targetType": "page"
//     },
//     {
//       "operation": "purge",
//       "targetType": "attachment"
//     }
//   ]
// }

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

ls_V_type = loo_JResp.StringOf("type")
ls_Path = loo_JResp.StringOf("profilePicture.path")
li_Width = loo_JResp.IntOf("profilePicture.width")
li_Height = loo_JResp.IntOf("profilePicture.height")
li_IsDefault = loo_JResp.BoolOf("profilePicture.isDefault")
ls_DisplayName = loo_JResp.StringOf("displayName")
ls_Operations = loo_JResp.StringOf("_expandable.operations")
i = 0
li_Count_i = loo_JResp.SizeOfArray("operations")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Operation = loo_JResp.StringOf("operations[i].operation")
    ls_TargetType = loo_JResp.StringOf("operations[i].targetType")
    i = i + 1
loop


destroy loo_Http
destroy loo_QueryParams
destroy loo_SbResponseBody
destroy loo_JResp

Curl Command

curl -G -d "expand=%3Cstring%3E"
	-d "expand=%3Cstring%3E"
	-H "Authorization: Bearer <access_token>"
https://your-domain.atlassian.net/wiki/rest/api/user/anonymous

Postman Collection Item JSON

{
  "name": "Get anonymous user",
  "request": {
    "auth": {
      "type": "oauth2"
    },
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/api/user/anonymous?expand=<string>&expand=<string>",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "user",
        "anonymous"
      ],
      "query": [
        {
          "key": "expand",
          "value": "<string>",
          "description": "A multi-value parameter indicating which properties of the user to\nexpand.\n\n  - `operations` returns the operations that the user is allowed to do."
        },
        {
          "key": "expand",
          "value": "<string>",
          "description": "A multi-value parameter indicating which properties of the user to\nexpand.\n\n  - `operations` returns the operations that the user is allowed to do."
        }
      ]
    },
    "description": "Returns information about how anonymous users are represented, like the\nprofile picture and display name.\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 anonymous user representation is 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/anonymous?expand=<string>&expand=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "user",
            "anonymous"
          ],
          "query": [
            {
              "key": "expand",
              "value": "<string>"
            },
            {
              "key": "expand",
              "value": "<string>"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"type\": \"non ut\",\n \"profilePicture\": {\n  \"path\": \"id pariatur occaecat cillum\",\n  \"width\": 98006898,\n  \"height\": 65551585,\n  \"isDefault\": true\n },\n \"displayName\": \"eiusmod\",\n \"_expandable\": {\n  \"operations\": \"Duis\"\n },\n \"_links\": {},\n \"operations\": [\n  {\n   \"operation\": \"purge\",\n   \"targetType\": \"page\"\n  },\n  {\n   \"operation\": \"purge\",\n   \"targetType\": \"attachment\"\n  }\n ]\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/anonymous?expand=<string>&expand=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "user",
            "anonymous"
          ],
          "query": [
            {
              "key": "expand",
              "value": "<string>"
            },
            {
              "key": "expand",
              "value": "<string>"
            }
          ]
        }
      },
      "status": "Forbidden",
      "code": 403,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}