Chilkat Online Tools

PowerBuilder / Atlassian Confluence Cloud / Convert user identifiers to account IDs in CQL queries

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_Json
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode

// 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

// Use this online tool to generate code from sample JSON: Generate Code to Create JSON

// The following JSON is sent in the request body.

// {
//   "queryStrings": [
//     "<string>",
//     "<string>"
//   ]
// }

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

loo_Json.UpdateString("queryStrings[0]","<string>")
loo_Json.UpdateString("queryStrings[1]","<string>")

loo_Http.SetRequestHeader("Content-Type","application/json")

loo_Resp = loo_Http.PostJson3("https://your-domain.atlassian.net/wiki/rest/experimental/cql/pdcleaner","application/json",loo_Json)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_Json
    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_Json
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

destroy loo_Resp


destroy loo_Http
destroy loo_Json
destroy loo_SbResponseBody
destroy loo_JResp

Curl Command

curl -X POST
	-H "Content-Type: application/json"
	-d '{
    "queryStrings": [
        "<string>",
        "<string>"
    ]
}'
https://your-domain.atlassian.net/wiki/rest/experimental/cql/pdcleaner

Postman Collection Item JSON

{
  "name": "Convert user identifiers to account IDs in CQL queries",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"queryStrings\": [\n        \"<string>\",\n        \"<string>\"\n    ]\n}"
    },
    "url": {
      "raw": "{{baseUrl}}/experimental/cql/pdcleaner",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "experimental",
        "cql",
        "pdcleaner"
      ]
    },
    "description": "Converts one or more CQL queries with user identifiers (username or user key)\nto equivalent CQL queries with account IDs.\n\nYou may wish to use this operation if your system stores CQL queries and you\nwant to make them GDPR-compliant. For more information about GDPR-related changes,\nsee the [migration guide](https://developer.atlassian.com/cloud/confluence/deprecation-notice-user-privacy-api-migration-guide/).\n\n**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: None"
  },
  "response": [
    {
      "name": "Returned if the request is successful. The CQL queries are returned\nin the same order that they were passed. Note that if the user in a\nCQL query cannot be found, a `200` code is still returned but the username\nor key is converted to an empty string.",
      "originalRequest": {
        "method": "POST",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"queryStrings\": [\n        \"<string>\",\n        \"<string>\"\n    ]\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/experimental/cql/pdcleaner",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "experimental",
            "cql",
            "pdcleaner"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "\"{ \\\"queryStrings\\\": [ \\\"type = page and creator != '847586:5371623a-12b4-1a11-ed01-a53542f02dd1' and space = DEV\\\"] }\""
    },
    {
      "name": "Returned if:\n\n* At least one of the queries cannot be converted. For example, the\nCQL has invalid operators or invalid keywords.\n* More than 100 CQL queries are included in the request.",
      "originalRequest": {
        "method": "POST",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"queryStrings\": [\n        \"<string>\",\n        \"<string>\"\n    ]\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/experimental/cql/pdcleaner",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "experimental",
            "cql",
            "pdcleaner"
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}