addSpaceWatcher method

Future<void> addSpaceWatcher({
  1. required String xAtlassianToken,
  2. required String spaceKey,
  3. String? key,
  4. String? username,
  5. String? accountId,
})

Adds a user as a watcher to a space. Choose the user by doing one of the following:

  • Specify a user via a query parameter: Use the accountId to identify the user.
  • Do not specify a user: The currently logged-in user will be used.

Note, you must add the X-Atlassian-Token: no-check header when making a request, as this operation has XSRF protection.

Permissions required: 'Confluence Administrator' global permission if specifying a user, otherwise permission to access the Confluence site ('Can use' global permission).

Implementation

Future<void> addSpaceWatcher(
    {required String xAtlassianToken,
    required String spaceKey,
    String? key,
    String? username,
    String? accountId}) async {
  await _client.send(
    'post',
    'wiki/rest/api/user/watch/space/{spaceKey}',
    pathParameters: {
      'spaceKey': spaceKey,
    },
    queryParameters: {
      if (key != null) 'key': key,
      if (username != null) 'username': username,
      if (accountId != null) 'accountId': accountId,
    },
    headers: {
      'X-Atlassian-Token': 'no-check',
    },
  );
}