Search code examples
bitbucketbitbucket-api

Filtering branches with BitBucket REST API


I'm new to the BitBucket REST API and I'm having an issue I hope that someone can help me with.

I'm attempting to get information about a branch, 'TEST-BRANCH'. After reading this page: https://confluence.atlassian.com/bitbucket/version-2-423626329.html, here is my curl command:

curl --user {user}:{password} https://api.bitbucket.org/2.0/repositories/{user}/{slug}/refs/branches?q=name+%7E+%22TEST-BRANCH%2F%22

However, the response that I receive from making this curl request is as follows:

{"pagelen": 10, "values": [], "page": 1, "size": 0}

When I run the curl command without the filters: curl --user {user}:{password} https://api.bitbucket.org/2.0/repositories/{user}/{slug}/refs/branches

I get a massive list of all my branches and I can clearly see the TEST-BRANCH there with "type": "branch", "name": "TEST-BRANCH"

What have I missed here?

Thanks, axl


Solution

  • It looks the query contains an extra %2F character - the string decodes to "TEST-BRANCH/". Remove that %2F and you should be good to go.