Client methods (e.g., GitApi.getRepositoriesPaged in the demonstration below) do not seem to set the continuationToken property of the PagedList<T> object returned. Without the continuationToken, there is no way to get the next page of results.
Demonstration
Name of the organization and project has been anonymized in the code below.
import { getPersonalAccessTokenHandler, WebApi } from "./WebApi";
async function main() {
const token = process.env.AZURE_DEVOPS_PAT || "";
const handler = getPersonalAccessTokenHandler(token);
const webApi = new WebApi("https://dev.azure.com/organization/", handler);
const gitApi = await webApi.getGitApi();
{
console.log("Without Pagination");
const repositories = await gitApi.getRepositories("project");
console.log(` # Repositories: ${repositories.length}`);
}
console.log("----------------------");
{
console.log("With Pagination (top = 10)");
const repositories = await gitApi.getRepositoriesPaged(
"project",
undefined,
undefined,
undefined,
undefined,
10
);
console.log(` # Repositories: ${repositories.length}`);
console.log(` Continuation Token: ${repositories.continuationToken}`);
}
}
main();
Output
As shown below, there are 326 repositories returned by GitApi.getRepositories. However, when GitApi.getRepositoriesPaged (which returns PagedList<GitRepository>>) with top set to 10 is used, the continuationToken property of PagedList<GitRepository> is not set, preventing the requesting of next page of repositories.
Output shown below is from a Microsoft-internal Azure DevOps project.
$ npx ts-node api/scratch.ts
Without Pagination
# Repositories: 326
----------------------
With Pagination
# Repositories: 10
Continuation Token: undefined
I have verified that the repositoriesPaged endpoint returns the continuation token in the x-ms-continuationtoken response header, but the methods that return PagedList<T> do not appear to be setting the continuationToken property with the value of the x-ms-continuationtoken response header.
$ curl -s -D - -o /dev/null -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
"https://dev.azure.com/organization/_apis/git/project/repositoriesPaged?%24top=10" | grep x-ms-continuationtoken
x-ms-continuationtoken: repository-eleven
Client methods (e.g.,
GitApi.getRepositoriesPagedin the demonstration below) do not seem to set thecontinuationTokenproperty of thePagedList<T>object returned. Without thecontinuationToken, there is no way to get the next page of results.Demonstration
Output
As shown below, there are 326 repositories returned by
GitApi.getRepositories. However, whenGitApi.getRepositoriesPaged(which returnsPagedList<GitRepository>>) withtopset to10is used, thecontinuationTokenproperty ofPagedList<GitRepository>is not set, preventing the requesting of next page of repositories.I have verified that the
repositoriesPagedendpoint returns the continuation token in thex-ms-continuationtokenresponse header, but the methods that returnPagedList<T>do not appear to be setting thecontinuationTokenproperty with the value of thex-ms-continuationtokenresponse header.