Using pagination for /2.0/repositories
Asked by Julien Delange:

We are maintaining a Bitbucket app. We have customer complaints that we are not showing all repositories. It seems this is a bug in the Bitbucket API.

The pagination seems broken. The request

```
https://api.bitbucket.org/2.0/repositories?page=1&pagelen=10&role=owner
```

returns the same result than

```
https://api.bitbucket.org/2.0/repositories?page=2&pagelen=10&role=owner
```

In fact, changing the number of page in the request parameter does not seem to have any effect.

There are the results from an impacted customer:

**Page 1**

```
$curl -H "Authorization: JWT <jwt>" 'https://api.bitbucket.org/2.0/repositories?page=1&pagelen=10&role=owner' | jq -r ".values[].slug"

project1
project2
```

**Page 2**

```
$ curl -H "Authorization: JWT <jwt>" 'https://api.bitbucket.org/2.0/repositories?page=2&pagelen=10&role=owner' | jq -r ".values[].slug"

project1
project2
```

The correct behavior should be to have a different list of values for each page.

Am I doing anything wrong?

**Note**: it would be really cool to be able to write content with markdown on this forum.


Answers:
author: Ben
body: Hey Julien,

I have tested this from my end using AppPassword as the authentication method and was unable to reproduce this issue - I am able to see a list of 10 repositories belonging to my workspaceID and viewing page 2 shows the remaining 4 repositories attributed to my workspaceID:

```
curl -X GET \
--url 'https://api.bitbucket.org/2.0/repositories/{workspaceID}?page=1&pagelen=10&role=owner' \
--user {username}:{AppPassword}

curl -X GET \
--url 'https://api.bitbucket.org/2.0/repositories/{workspaceID}?page=2&pagelen=10&role=owner' \
--user {username}:{AppPassword}
```

NOTE: you will need to remove the curly braces and replace workspaceID, username and AppPassword with actual values.

Can you try the above and let me know how this goes?

Cheers!

- Ben (Bitbucket Cloud Support)

comments: author: Julien Delange
body: Hi [@Ben](/t5/user/viewprofilepage/user-id/4537226) and sorry for the late reply. We do not have the application user or their password. We have a Bitbucket App and only authenticate through a JWT. This is how Bitbucket Applications authenticate (link to [Bitbucket doc](https://developer.atlassian.com/cloud/bitbucket/authentication-for-apps/#making-a-service-call-1)).

To this day, we will have the issue and more customers complained.


author: Ben
body: Hi [@Julien Delange](/t5/user/viewprofilepage/user-id/3786167)

My apologies - I have attempted to re-create your environment by creating a test app, and running a NodeJS server with Ngrok to be able to generate a JWT but I have been unsuccessful. I do not have much knowledge of NodeJS code so this is probably the main issue I'm facing :/

To avoid any further delay, I would suggest reaching out to our developer community as they would be better equipped to assist you further:  
<https://community.developer.atlassian.com/c/bitbucket-development/bitbucket-cloud/13>

Cheers!

- Ben (Bitbucket Cloud Support)


author: Julien Delange
body: Thank you! I created the following error (for traceability of folks that want to keep track of the issue) <https://community.developer.atlassian.com/t/using-pagination-for-2-0-repositories/65321>


Tags: bitbucket-cloud

cloud