Forums

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

Bitbucket Server API, Removing user from Group

Matt Kimball October 26, 2021

Good Day All, I am attempting to remove a user from a group on my Bitbucket Server(v7.1.1) using the RestAPI via curl. I'm following the doc here(https://docs.atlassian.com/bitbucket-server/rest/7.6.0/bitbucket-rest.html#idp36)

Here is the curl syntax I am using

curl -D- -u user:* -X GET -H "Content-Type: application/json" "https://*.*.com:8443/rest/api/1.0/admin/users/remove-group?&context=johnsmith&itemName=group1"

Here is my response error

HTTP/1.1 405
Cache-Control: private
Expires: Thu, 01 Jan 1970 00:00:00 GMT
X-AREQUESTID: @KLMZ8Ux485x1589179x0
X-ASEN: SEN-11523232
X-AUSERID: 1
X-AUSERNAME: user
Allow: POST,OPTIONS
X-Content-Type-Options: nosniff
vary: accept-encoding
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Date: Tue, 26 Oct 2021 13:05:13 GMT

What can I do to fix my request? Maybe I am missing something in my syntax, I'm having trouble debugging this, I appreciate any advice here! Thank you.

1 answer

1 accepted

1 vote
Answer accepted
Maciej Adamczak
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 26, 2021

Hey @Matt Kimball , Looking at the docs I think you need to use POST request, not a GET. Additionally, you need to covert the URL params to a JSON type payload.

You can click the "expand" button next to "Example request representations" to find the example JSON payload.

Don't forget to configure required headers to send a JSON request e.g. for cURL that will be "-H "Content-Type: application/json"

 

Thanks,
Maciej Adamczak
Atlassian Developer

Matt Kimball October 27, 2021

Thank you @Maciej Adamczak ! I made the changes you suggested and I am getting much better results now. Here is the syntax I am using

curl -D- -u "user:*" -X POST -H "Content-Type: application/json" -d "{\"context\": \"johnsmith\",\"itemName\": \"group1\"}" "https://*.*.com:8443/rest/api/1.0/admin/users/remove-group" 
Like Maciej Adamczak likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events