Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Bitbucket REST API - reference branches with forward slash in name

Hello everyone!

I am having trouble figuring out how one can reference branches with the forward slash / character in the name while making API calls.

When using URL encoding, Bitbucket will assume that the encoded forward slash (%2F) is a path parameter delimiter.

A simple example: trying to access README.md on a branch called "feature/test" with the following command will fail, as Bitbucket will try to access it on the non-existent "feature" branch, and will assume "test" is part of the path.

Request:  curl 'https://api.bitbucket.org/2.0/repositories/my-workspace/myrepository/src/feature%2Ftest/README.md'

Response: {"data":{"shas":["feature"]},"type":"error","error":{"message":"Commit not found","data":{"shas":["feature"]}}}

Is there any workaround for this? Because I've been searching for similar issues and so far haven't come up with anything.

1 answer

Oh, probably shouldn't be holding my breath over this one...

https://jira.atlassian.com/browse/BCLOUD-20223

Anyone know of a workaround?

seanaty Atlassian Team Jan 03, 2022

Work around is to make 2 API calls. Use the branch API to get the current commit of that branch, then use the current commit to call the source API.

Like Mark Hegedus likes this

Hi @seanaty ! Thank you for your quick reply, this solution works.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

⭐ Calling all Bitbucket and DevOps experts: Special showcase opportunity ⭐

Hi, Bitbucket community! Are you a DevOps practitioner (or know one in your network)? Do you have DevOps tips, tricks, or learnings you'd like to share with the community? If so, we'd love to hea...

1,523 views 4 8
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you