Missed Team ’24? Catch up on announcements here.

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

Bitbucket REST Api: How can I order all branches by date desc with rest api call ?

Mert Malçok
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 10, 2018

Hello,

I need to get the name of the latest branch. So, I list branches but the order of the list is not by created date desc.

And the below api call doesn't work. Its response is like that "message": "Invalid field name: updated_on"

https://api.bitbucket.org/2.0/repositories/{user_name}/{repo_name}/refs/branches?sort=-updated_on

Thanks & Best Regards,

Mert

1 answer

1 accepted

0 votes
Answer accepted
Mert Malçok
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 10, 2018

I've found the answer. All branches have target field and the target has date field. So, in order to sort the branches by date you need to point target's date by "target.date"

Like below:

https://api.bitbucket.org/2.0/repositories/{user_name}/{repo_name}/refs/branches?sort=-target.date

Tom Smith
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 8, 2018

Hi Mert,

 

Is this still working for you? I found that the branches were returned in the underlying source control system (for git) and weren't sorted by last updated.

 

Tom

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events