Closed
Description
openedon Jan 28, 2024
Environment
Node version: v20.10.0
Npm version: 10.2.3
OS and version: macOS 13.6.3
azure-devops-node-api version: 12.3.0
Issue Description
I am using Azure DevOps free plan. I have create a PAT with full access.
When I try to create a getAPI object with connection.getGitApi()
, it returns an error.
Here is my code:
export const commentOnPR = async (
comment: string
): Promise<void> => {
console.log(comment);
try {
const { organization, azureToken, pullRequestId, repositoryId, project } =
gitAzureEnvVariables();
// your collection url
const orgUrl = `https://dev.azure.com/${organization}/`;
const pullRequestIdNumber = Number(pullRequestId);
console.log({ organization, azureToken, pullRequestId, repositoryId, project });
const authHandler = azdev.getPersonalAccessTokenHandler(azureToken); // The PAT has Full permissions
console.log('authHandler', authHandler);
const connection = new azdev.WebApi(orgUrl, authHandler);
console.log('connection', connection);
const gitApiObject: gitApiObject.IGitApi = await connection.getGitApi(); // the error throw form this line
const repos: GitInterfaces.GitRepository[] = await gitApiObject.getRepositories(project);
console.log("There are", repos.length, "repositories in this project");
const threads: GitInterfaces.GitPullRequestCommentThread[] =
await gitApiObject.getThreads(repositoryId, pullRequestIdNumber, project);
console.log('threads', threads);
const prComment: GitInterfaces.Comment = <GitInterfaces.Comment>{
content: comment,
};
// createComment(comment: GitInterfaces.Comment, repositoryId: string, pullRequestId: number, threadId: number, project?: string): Promise<GitInterfaces.Comment>;
await gitApiObject.createComment(
prComment,
repositoryId,
pullRequestIdNumber,
threads[0].id || 0,
project
);
} catch (error) {
console.log(error);
logger.error(`Failed to comment on PR: ${JSON.stringify(error)}`);
throw error;
}
Expected behaviour
It should create a comment for the specific PR
Actual behaviour
Error: Failed to find api location for area: Location id: e81700f7-3be2-46de-8624-2eb35882fcaa
Logs
Error: Failed to find api location for area: Location id: e81700f7-3be2-46de-8624-2eb35882fcaa
at code-review-gpt/packages/code-review-gpt/node_modules/azure-devops-node-api/VsoClient.js:85:23
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment