Skip to content

GitRestClient.getCommitsBatch does not specify api version #157

@peer-jslater

Description

@peer-jslater

The api call:
getCommitsBatch(searchCriteria: Git.GitQueryCommitsCriteria, repositoryId: string, project?: string, skip?: number, top?: number, includeStatuses?: boolean): Promise<Git.GitCommitRef[]>;

Results in the error message:

POST: 
https://{instance}/{collection}/{project}/_apis/git/repositories/GUID/CommitsBatch?%24skip=0&%24top=1&includeStatuses=false
400 (Bad Request)

Image

I can copy the uri from the error message, paste it into postman and add: "&api-version=7.0" (and use a generated PAT for Basic authentication) and get 200 OK.

Image

Code used to call the function:

let criteria: GitQueryCommitsCriteria = EmptyGitQueryCommitsCriteria;

const MaxCommitsAllowedByApi = 1; // want to use 50000 here when I fix this. 
criteria.$top = MaxCommitsAllowedByApi;
criteria.itemPath = ....;
commits = await gitClient.getCommitsBatch(criteria, repoId, projectName, 0, MaxCommitsAllowedByApi, false);

package.json

    "dependencies": {
        "axios": "^1.8.3",
        "azure-devops-extension-api": "^4.248.1",
        "azure-devops-extension-sdk": "^4.0.2",
        "azure-devops-ui": "^2.254.0",
        "react": "^16.14.0",
        "react-dom": "^16.14.0"
    }

Work around: use the non-batch version of the function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions