Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to search branches by name with pagination

Milos Petrovic
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!
March 3, 2023

I am using the next endpoint to search for the branches, GET /2.0/repositories/{workspace}/{repo_slug}/refs/branches.

Separately both the pagination and query searching work, but when combined an error is return. The error says "Invalid Page"

List Branches DOCS 

---

Steps to reproduce ( using the example from the DOCS )

1. The docs provide the next url as an example ( I have just updated the pagelen and page to return the first 10 results ): 

https://api.bitbucket.org/2.0/repositories/atlassian/aui/refs/branches?pagelen=10&page=1

2. If we add a query to search by name the error will be returned:

https://api.bitbucket.org/2.0/repositories/atlassian/aui/refs/branches?pagelen=10&page=1&q=name~"issue"

3. If we remove the `page` query parameter, the data will be returned:

https://api.bitbucket.org/2.0/repositories/atlassian/aui/refs/branches?pagelen=10&page=1&q=name~"issue"

---

So it looks like there is some issue with the "page" query parameter?
Or am I doing something wrong?

1 answer

0 votes
Erez Maadani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 5, 2023

Hey @Milos Petrovic 

Try removing the `page` parameter from the request and use the returned URL from the `next` attribute in the response.

Milos Petrovic
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!
March 13, 2023

Hey @Erez Maadani

Yes this works!  Thanks

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events