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

The page filter doesnt work for fetching tags and fetching commits for a given pull request id

Akshara Anilkumar September 10, 2023

I tried using the page filter to this end point and it doesn't work:

curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/pullrequests/{pull_request_id}/commits' \ --header 'Authorization: Bearer <access_token>'

 

Also the page filter doesn't work for this as well:

curl --request GET \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/refs/tags' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json'

page response.PNG

1 answer

1 accepted

0 votes
Answer accepted
Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 11, 2023

G'day @Akshara Anilkumar 

I have tested the PR commit endpoint and have no issue getting the response. Example curl I used:

curl -X GET -u <username>:<appPassword> https://api.bitbucket.org/2.0/repositories/<WorkspaceID>/<RepoName>/pullrequests/<PRNumber>/commits    

The same goes for the "/refs/tags" endpoint. I wonder if your authorization is incorrect. Could you try using the above example with the App Password and see if you succeeded?

Regards,
Syahrul

Akshara Anilkumar September 12, 2023

Hi @Syahrul

Yes that endpoint works but the issue is that the "page" filter doesn't work for those endpoints.

I am giving this endpoint: https://api.bitbucket.org/2.0/repositories/ck-mux-bitbucket-connector/bitbucket_repo/pullrequests/9/commits?page=1

Even for fetching the tags , its the same issue. The page filter doesn't work.

then the response is: 

{
    "type""error",
    "error": {
        "message""Invalid page"
    }
}
Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 12, 2023

Hey @Akshara Anilkumar 

Noted. Does your PR commits list have a next page if that's the case? Could you try fetching the information without the filter page parameter and scroll down to see if any second page exists?

Alternatively, you can use ?pagelen=100 to show the 100 objects in a single response.

Let me know how it goes.

Regards,
Syahrul

Akshara Anilkumar September 24, 2023

Hi @Syahrul 

Yes next page exist for PR commit. Currently that's how I am checking. This is just a feedback it would be great , if you could make the page filter work as things will be much easier to check the information.

Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 24, 2023

Hi @Akshara Anilkumar 

Interesting. Have you tried adding ?pagelen=100 and see if that helps? I can't reproduce the behaviour, so I am curious to understand this issue further.

Regards,
Syahrul

Akshara Anilkumar September 25, 2023

Hi @Syahrul 

Yes it will work with the pagelen end point but what if we have more than 100 commits , then at that point we will have to search on basis of page number for which the page filter has to be used. I hope you understood the necessity of the end point.

 

Regards,

Akshara

Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 25, 2023

Hi @Akshara Anilkumar 

Thanks for the update.

Upon further inspection, I found out that what you saw was an expected behaviour because. API clients are not likely to construct URLs themselves by manipulating the page number query parameter.

Instead, the response contains a link to the next page. This link should be treated as an opaque location that is not to be constructed by clients or even assumed to be predictable. The only contract around the next link is that it will return the next chunk of results.

Please check the following pagination to understand how our pagination works:

Bitbucket pagination 

Regards,
Syahrul

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events