The page filter doesnt work for fetching tags and fetching commits for a given pull request id
Asked by Akshara Anilkumar:

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](https://community.atlassian.com/t5/image/serverpage/image-id/279739i6BCA7C2ADD6864F9/image-size/large?v=v2&px=999 "page response.PNG")


Answers:
author: Syahrul
body: G'day [@Akshara Anilkumar](/t5/user/viewprofilepage/user-id/5304231)

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](https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/) and see if you succeeded?

Regards,  
Syahrul

comments: author: Akshara Anilkumar
body: Hi [@Syahrul](/t5/user/viewprofilepage/user-id/744536)

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"  
}  
}


author: Syahrul
body: Hey [@Akshara Anilkumar](/t5/user/viewprofilepage/user-id/5304231)

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


author: Akshara Anilkumar
body: Hi [@Syahrul](/t5/user/viewprofilepage/user-id/744536)

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.


author: Syahrul
body: Hi [@Akshara Anilkumar](/t5/user/viewprofilepage/user-id/5304231)

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


author: Akshara Anilkumar
body: Hi [@Syahrul](/t5/user/viewprofilepage/user-id/744536)

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


author: Syahrul
body: Hi [@Akshara Anilkumar](/t5/user/viewprofilepage/user-id/5304231)

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](https://developer.atlassian.com/cloud/bitbucket/rest/intro/#pagination)

Regards,  
Syahrul


Tags: bitbucket-cloud

cloud