I'm having some trouble with the VSTS Node Api - specifically, the Identities API.
I've already successfully used the Git API to perform actions like retrieving a list of repositories:
// From ./functions/functions.js
module.exports.getRepos = async function (vstsWebApi) {
var gitApi = vstsWebApi.getGitApi();
var repos = await gitApi.getRepositories();
return repos;
}
Then, elsewhere, the following works as expected and the object representing the Git repositories is logged to the console:
let funcs = require("./functions/functions.js");
let vsts = require("vso-node-api");
let accessTokenPromise = VSS.getAccessToken();
accessTokenPromise.then(token => {
let bearerHandler = vsts.getBearerHandler(token.token);
let collectionUri = VSS.getWebContext().collection.uri;
let connect = new vsts.WebApi(collectionUri, bearerHandler);
let apiCallPromise = funcs.getRepos(connect);
apiCallPromise.then(
result => {
console.log(result);
}
)
})
However, if I try to do something similar and use the Identities API to listGroups
:
module.exports.getGroups = async function (vstsWebApi) {
var identitiesApi = vstsWebApi.getIdentitiesApi();
var groups = await identitiesApi.listGroups();
return groups;
}
Changing the promise to getGroups instead of getRepos...
...
let apiCallPromise= funcs.getGroups(connect);
apiCallPromise.then(
result => {
console.log(result);
}
...
...I get this error:
Error: Failed to find api location for area: IMS id: 5966283b-4196-4d57-9211-1b68f41ec1c2
I'm trying this on my personal VSTS account, so I should be the owner/Administrator - and I'd expect a different error if my access was denied via a permissions issue. I've tried different values for the collectionUri
, like including the project name (my-account.visualstudio.com/ProjectABC) but that doesn't work either. I've also tried other Identities API calls, such as getSelf
, with the same result.
I submit a feedback here: Identities API in VSTS-Node-API preview version, you can vote and follow it.