Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,369,738
Community Members
 
Community Events
168
Community Groups

Remove default space watch for new users via API

Hello,

my goal is to remove the default space watch of newly created users.

so i managed to get space watchers and their affiliated account id by requesting:

GET /wiki/rest/api/space/SPACEKEY/watch

 

Followed by:

DELETE /wiki/rest/api/user/watch/space/SPACEKEY?accountid=ACCOUNTID

i'm getting status code 204 which is a sucess by documentation, but the user is not deleted from space watches.

 

Am i getting something wrong here? Is this a bug?

2 answers

1 accepted

1 vote
Answer accepted

Hi @t.lange

welcome to the Atlassian Community.

Your requests look quite fine, I‘ve just spotted one difference, comparing it to the documentation in the accountId parameter. The I is uppercase - depending on the implementation of the API, that might be the solution.

Cheers,
Matthias

PS: I‘m replying from mobile currently, otherwise I‘d check myself.

Darryl Lee Community Leader Nov 09, 2021

Ooof, nevermind my overly long post. @Matthias Gaiser _K15t_ nailed it - it's the capital I. Doh.

Um, CLI is still a handy tool though. :-}

Like Matthias Gaiser _K15t_ likes this

Thanks both of you!

It worked out fine with capital "I" in the request.

1 vote
Darryl Lee Community Leader Nov 09, 2021

Whoops. Replied in the wrong question:

So I cheated and used Bob Swift's excellent Command-Line client. I think your issue is that you need add latest as part of the URL:

DELETE /wiki/rest/api/latest/user/watch/space/SPACEKEY?accountid=ACCOUNTID

When I used its removeWatch command with verbose (-v) enabled, I saw this:

% acli wiki -v --action removeWatch --space HELP --userId ACCOUNTID
URL requested: https://MYSITE.atlassian.net/wiki/rest/api/latest/user/watch/space/HELP?accountId=ACCOUNTID
Request type: DELETE
Content type: application/json; charset=utf-8
Response code: 204, message: No Content, url: https://MYSITE.atlassian.net/wiki/rest/api/latest/user/watch/space/HELP?accountId=ACCOUNTID

When I tried to replicate this using the renderRequest command (because I hate dealing with authentication tokens), the key thing to make it work was getting the Content type correct:

% acli wiki -v --action renderRequest --type "JSON" --requestType DELETE --request 'rest/api/latest/user/watch/space/HELP?accountId=ACCOUNTID'

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events