Hi all,
Using the REST API we are trying to retrieve data about branches in the workspace.
Using https://api.bitbucket.org/2.0/repositories/{workspace}/(repository}/refs/branches we get a response exampled in the link. It has values holding the various branches but does not hold any of the wanted data - author, created date etc.
Unless it is the data specified under 'target' .. Is that the case (target references the requested branch), or are we using it wrong?
response example
Thanks!
G'day Tomer!
Welcome to the Bitbucket Cloud community!
To retrieve information about certain ref types (ie branches/tags), you would need to modify the URL slightly by adding "/branches" or "/tags" after "ref", for example:
https://api.bitbucket.org/2.0/repositories/{workspace}/(repository}/refs/brancheshttps://api.bitbucket.org/2.0/repositories/{workspace}/(repository}/refs/tags
To filter this information further (for example - looking for a certain branch) the format is:
name ~ "insertnamehere"
Formatting this to unicode, you can include this in the url with the ?q parameter to view information about a certain branch:
https://api.bitbucket.org/2.0/repositories/{workspace}/(repository}/refs/branches?q=name~"{branchname}"
Further information regarding querying/sorting can be found here:https://developer.atlassian.com/cloud/bitbucket/rest/intro/#filtering
Hope this helps.
Cheers!
- Ben (Bitbucket Cloud Support)
.
Hi Ben,
Thanks for your response. As detailed, we are using the URL as you provided -
https://api.bitbucket.org/2.0/repositories/{workspace}/(repository}/refs/branches
but we do not see the data we are looking for. Maybe asking this differently - what is the data provided under "target" in the response JSON?
We couldn't find what the target is referencing to.
Thanks again!
Hey Tomer,
Target refers to a few fields, "type", "hash" and "date", for example:
"type": "commit","hash": "b41a86ce2a7b1bd0c002743240a7cf93c09ce513","date": "2022-11-23T05:25:56+00:00",
This provides details about the branches, for example the latest commit hash and the date that the branch was last committed to.
What is the information you are hoping to return from the branches?
It looks like you're new here. Sign in or register to get started.