Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,466,769
Community Members
 
Community Events
176
Community Groups

how to add existing user group to repository on bitbucket with REST API

Edited

Hi I'm trying to create a script which will add existing user group to repository on bitbucket.

I tried something like this: 

 

groups_for_adding = f'https://api.bitbucket.org/1.0/group-privileges/{workspace}/{repo}/{groupname} --data write'
response = requests.put(groups_for_adding, auth=HTTPBasicAuth(username, password))
print(response)

 

Also tried solutions from this link:

https://support.atlassian.com/bitbucket-cloud/docs/invitations-endpoint/

 

Any help is very welcomed... :)

 

1 answer

0 votes
Mark C Atlassian Team Apr 20, 2022

Hi @ext_momcilo_vasic

Welcome to the community.

I've checked our API v1 documentation and compared it with the endpoint you've used and I believe you're just missing the "group_owner" which is the same as the workspace ID.

You can check the documentation on this link (Under "PUT group privileges on a repository").

Here's the exact endpoint:

PUT https://api.bitbucket.org/1.0/group-privileges/{workspace_id}/{repo_slug}/{group_owner}/{group_slug} --data "{privilege}"

As an example, if your repository is: some_workspace/some_repo
And your user group name is: some_group

The API endpoint would be:

https://api.bitbucket.org/1.0/group-privileges/some_workspace/some_repo/some_workspace/some_group

Btw, please also make sure you're using an App password (as your password credential) as we recently deprecated the Atlassian account password.

Hope it helps and do let me know if you have further questions that I can help with.

Regards,
Mark C

thanks for the answer, with this api I'm getting following answer

curl --request PUT --user user:password PUT https://api.bitbucket.org/1.0/group-privileges/{workspace_id}/{repo_slug}/{group_owner}/{group_slug} --data "{privilege}"

is not a valid privilege

tried with this commands:

curl --request PUT --user user:password https://api.bitbucket.org/1.0/group-privileges/some_workspace/some_repo/some_workspace/some_group --data read

curl --request PUT --user user:password https://api.bitbucket.org/1.0/group-privileges/some_workspace/some_repo/some_workspace/some_group --data "read"

 

any idea what is wrong?

Mark C Atlassian Team Apr 21, 2022

Hi @ext_momcilo_vasic

I've tried the similar CURL Command below, however, it works fine on my end using an App password.

curl --request PUT --user user:password https://api.bitbucket.org/1.0/group-privileges/some_workspace/some_repo/some_workspace/some_group --data read

Would you be able to confirm if you're using an App password?
You can also try to add the flag -vv in your CURL command to debug it further and see what's happening when it tries to connect to Bitbucket.org.

Let me know how it goes.

Regards,
Mark C

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events