Chilkat Online Tools

TCL / Atlassian Confluence Cloud / Add label watcher

Back to Collection Items

load ./chilkat.dll

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

set http [new_CkHttp]

# Adds the "Authorization: Bearer <access_token>" header.
CkHttp_put_AuthToken $http "<access_token>"
CkHttp_SetRequestHeader $http "X-Atlassian-Token" "no-check"

# resp is a CkHttpResponse
set resp [CkHttp_QuickRequest $http "POST" "https://your-domain.atlassian.net/wiki/rest/api/user/watch/label/:labelName?key=<string>&username=<string>&accountId=<string>"]
if {[CkHttp_get_LastMethodSuccess $http] == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    exit
}

set respStatusCode [CkHttpResponse_get_StatusCode $resp]
puts "Response Status Code = $respStatusCode"
if {$respStatusCode != 204} then {
    puts "Response Header:"
    puts [CkHttpResponse_header $resp]
    puts "Response Body:"
    puts [CkHttpResponse_bodyStr $resp]
    puts "Failed."
    delete_CkHttpResponse $resp

    delete_CkHttp $http
    exit
}

delete_CkHttpResponse $resp

puts "Success."

delete_CkHttp $http

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-H "X-Atlassian-Token: no-check"
https://your-domain.atlassian.net/wiki/rest/api/user/watch/label/:labelName?key=<string>&username=<string>&accountId=<string>

Postman Collection Item JSON

{
  "name": "Add label watcher",
  "request": {
    "auth": {
      "type": "oauth2"
    },
    "method": "POST",
    "header": [
      {
        "description": "(Required) Note, you must add header when making a\nrequest, as this operation has XSRF protection.",
        "key": "X-Atlassian-Token",
        "value": "no-check"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/user/watch/label/:labelName?key=<string>&username=<string>&accountId=<string>",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "user",
        "watch",
        "label",
        ":labelName"
      ],
      "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 `accountId` of the user to be added as a watcher. The accountId uniquely identifies the user across all Atlassian products.\nFor example, `384093:32b4d9w0-f6a5-3535-11a3-9c8c88d10192`."
        }
      ],
      "variable": [
        {
          "key": "labelName",
          "value": "<string>",
          "type": "string",
          "description": "(Required) The name of the label to add the watcher to."
        }
      ]
    },
    "description": "Adds a user as a watcher to a label. Choose the user by doing one of the\nfollowing:\n\n- Specify a user via a query parameter: Use the `accountId` to identify the user.\n- Do not specify a user: The currently logged-in user will be used.\n\nNote, you must add the `X-Atlassian-Token: no-check` header when making a\nrequest, as this operation has XSRF protection.\n\n**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:\n'Confluence Administrator' global permission if specifying a user, otherwise\npermission to access the Confluence site ('Can use' global permission)."
  },
  "response": [
    {
      "name": "Returned if the watcher was successfully created. No response body is\nreturned.",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: oauth2",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "<token>"
          },
          {
            "description": "(Required) Note, you must add header when making a\nrequest, as this operation has XSRF protection.",
            "key": "X-Atlassian-Token",
            "value": "no-check"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/user/watch/label/:labelName?key=<string>&username=<string>&accountId=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "user",
            "watch",
            "label",
            ":labelName"
          ],
          "query": [
            {
              "key": "key",
              "value": "<string>"
            },
            {
              "key": "username",
              "value": "<string>"
            },
            {
              "key": "accountId",
              "value": "<string>"
            }
          ],
          "variable": [
            {
              "key": "labelName"
            }
          ]
        }
      },
      "status": "No Content",
      "code": 204,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "Returned if;\n\n- The `X-Atlassian-Token: no-check` header is not specified.\n- A user is specified via a query parameter and the calling user is\nnot a Confluence administrator.\n- No label exists for the specified `labelName`.",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: oauth2",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "<token>"
          },
          {
            "description": "(Required) Note, you must add header when making a\nrequest, as this operation has XSRF protection.",
            "key": "X-Atlassian-Token",
            "value": "no-check"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/user/watch/label/:labelName?key=<string>&username=<string>&accountId=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "user",
            "watch",
            "label",
            ":labelName"
          ],
          "query": [
            {
              "key": "key",
              "value": "<string>"
            },
            {
              "key": "username",
              "value": "<string>"
            },
            {
              "key": "accountId",
              "value": "<string>"
            }
          ],
          "variable": [
            {
              "key": "labelName"
            }
          ]
        }
      },
      "status": "Forbidden",
      "code": 403,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "Returned if no `labelName` is specified.",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: oauth2",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "<token>"
          },
          {
            "description": "(Required) Note, you must add header when making a\nrequest, as this operation has XSRF protection.",
            "key": "X-Atlassian-Token",
            "value": "no-check"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/user/watch/label/:labelName?key=<string>&username=<string>&accountId=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "user",
            "watch",
            "label",
            ":labelName"
          ],
          "query": [
            {
              "key": "key",
              "value": "<string>"
            },
            {
              "key": "username",
              "value": "<string>"
            },
            {
              "key": "accountId",
              "value": "<string>"
            }
          ],
          "variable": [
            {
              "key": "labelName"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}