Home > Enterprise >  Bitbucket Server API, Removing user from Group
Bitbucket Server API, Removing user from Group

Time:11-11

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.

CodePudding user response:

I found my solution. I needed to use POST instead of GET aswell as converting the parameters into a json payload. Syntax below is working for me.

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"  
  • Related