Chilkat Online Tools

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

Back to Collection Items

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vJson
    Handle hoJson
    Variant vResp
    Handle hoResp
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    String sTemp1
    Boolean bTemp1

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

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

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

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "queryStrings[0]" "<string>" To iSuccess
    Get ComUpdateString Of hoJson "queryStrings[1]" "<string>" To iSuccess

    Send ComSetRequestHeader To hoHttp "Content-Type" "application/json"

    Get pvComObject of hoJson to vJson
    Get ComPostJson3 Of hoHttp "https://your-domain.atlassian.net/wiki/rest/experimental/cql/pdcleaner" "application/json" vJson To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess

    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
    Set ComEmitCompact Of hoJResp To False

    Showln "Response Body:"
    Get ComEmit Of hoJResp To sTemp1
    Showln sTemp1

    Get ComStatusCode Of hoResp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComHeader Of hoResp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Send Destroy of hoResp
        Procedure_Return
    End

    Send Destroy of hoResp


End_Procedure

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