Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Remove default space watch for new users via API

Tim Lange November 9, 2021

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
Matthias Gaiser _K15t_
Community Champion
November 9, 2021

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 Champion
November 9, 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
Tim Lange November 10, 2021

Thanks both of you!

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

1 vote
Darryl Lee
Community Champion
November 9, 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, likes for trees, atlassian community, social impact, tree planting campaign, community kudos, atlassian giving, environmental impact, sustainability, likes for good, atlassian social responsibility, community challenge

Make every click count—help us plant 50,000 trees! 🌳

Want to make your everyday Community actions directly contribute to reforestation? The Atlassian Community can achieve this goal by liking a post, attending an ACE, sending your peers kudos, and so much more!

Help us plant more trees
AUG Leaders

Atlassian Community Events