User Tools

Site Tools


wiki:bitbucket_cloud_api_steps

Bitbucket Cloud API steps

Get oauth token

 curl -X POST -u "email:password" \
  https://bitbucket.org/site/oauth2/access_token \
  -d grant_type=client_credentials
 
 curl -sX POST -u "AUTHOKEN"   https://bitbucket.org/site/oauth2/access_token   -d grant_type=client_credentials
 
    {"access_token": "YOUR_LONG_ACCESS_TOKEN", "scopes": "pullrequest:write project:write account:write issue:write pipeline:variable snippet:write team:write webhook reposi...

Include above token in request on different endpoints

curl -s --header "Authorization: Bearer YOUR_LONG_ACCESS_TOKEN"   https://api.bitbucket.org/2.0/repositories | jq .

List repos

curl -s --header "Authorization: Bearer YOUR_LONG_ACCESS_TOKEN"   https://api.bitbucket.org/2.0/repositories/YOUR_USERNAME | jq .

Create new project (Mars example)

body=$(cat << EOF
{
    "name": "Mars Project",
    "key": "MARS",
    "description": "Software for colonizing mars.",
    "is_private": false
}
EOF
)
curl -s --header "Authorization: Bearer YOUR_LONG_ACCESS_TOKEN" --header "Content-Type: application/json"  -X POST -d "$body" https://api.bitbucket.org/2.0/teams/YOUR_TEAM/projects/ | jq .

Tested on

See also

References

wiki/bitbucket_cloud_api_steps.txt · Last modified: 2021/02/19 15:20 by antisa

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki