-
Notifications
You must be signed in to change notification settings - Fork 236
Description
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