How to get all users by project on Youtrack rest api?

I can't get users by project or by filter on YouTrack REST API;

I wrote the following code:

var login = "mylogin";
var password = "mypassword";

(async function getAllUserByProject(login, password, project) {
        var url = ``https://mycompany.myjetbrains.com/hub/api/rest/users?`;
        return new Promise((done, fail)=> {
            request.get({
                url, auth: {user: login, pass: password, sendImmediately: true}
            }, (error, body, result)=> {
                if (error || !result) {
                    return fail({
                        error: JSON.parse(error), result: result ? JSON.parse(result) : null
                    })
                }
                console.log(result)
                done(JSON.parse(result));
            })
        })
    }
)(login, password, project);

Upvotes: 0

Views: 3118

Answers (2)

fuglede
fuglede

Reputation: 18221

As of YouTrack 2018.3, the old REST API is becoming deprecated in favor of one that allows much more elaborate queries.

With the new API, you can use /hub/api/rest/projectteams/?$top=-1&fields=id to get the full list of ids of all project teams, and, for each of those, /hub/api/rest/projectteams/{project id}/users to get the list of users in a given project team.

Upvotes: 0

George Aristy
George Aristy

Reputation: 1481

Old question but:

users by project

Use /rest/admin/user?project=<PROJECT_ID>. I tested this on v2017.3 and it works.

Reference: https://www.jetbrains.com/help/youtrack/standalone/GET-Users.html

by filter

As seen in the documentation, the resource url takes the form of /rest/admin/user?{q}&{group}&{role}&{project}&{permission}&{onlineOnly}&{start} where:

  • q can be part of user login, name, or email
  • group is the user's groupID
  • role is the users's role
  • project see above
  • permission is one of the user's permissions
  • onlineOnly get only users which are currently online
  • start for pagination (page size fixed at 10)

Upvotes: 1

Related Questions