我正在使用C#中的一个工具来连接JIRA SOAP API.我已经阅读了可以在这里找到的文档:http://docs.atlassian.com/software/jira/docs/api/rpc-jira-plugin/latest/index.html
有谁知道如何获得特定项目的所有可分配用户的列表?我还没找到怎么做......
好的,我今天必须处于更好的状态,所以这里是我的问题的解决方案
////// object interface to the JIRA API /// private readonly JiraSoapServiceClient _JiraService; ////// authentication token returned by the login method /// that can be used on all other SOAP methods /// private readonly string _Token; ////// name of the RemoteProjectRole "Developers" /// private const string DEVELOPER_ROLE = "Developers"; ////// id of the RemoteProjectRole "Developers" /// private static long? _DeveloperId; ////// return the list of the names of all the users who have /// the role "Developers" in a project /// /// ///public List GetUsersForProject(string project) { List users = new List (); try { // get the RemoteProject RemoteProject rp = _JiraService.getProjectByKey(_Token, project); // get the "Developers" Prject Role RemoteProjectRole developerRole = getDeveloperRole(); if (developerRole != null) { // we can use this method only if the user logged in is an administrator RemoteRoleActors actors = _JiraService.getProjectRoleActors(_Token, developerRole, rp); foreach (RemoteRoleActor actor in actors.roleActors) { foreach (RemoteUser user in actor.users) { users.Add(user.name); } } } } catch (Exception ex) { // TODO log the error users.Clear(); } users.Sort(); return users; } /// /// return the RemoteProjectRole "Developers" /// ///private RemoteProjectRole getDeveloperRole() { RemoteProjectRole developerRole = null; if (_DeveloperId == null) { // the first time we call this function we don't know the id of this role // that's why we are obliged to find it with a foreach on all the project roles foreach (RemoteProjectRole role in _JiraService.getProjectRoles(_Token)) { if (role.name == DEVELOPER_ROLE) { developerRole = role; _DeveloperId = role.id; break; } } } else { // we have the id so we can get directly the RemoteProjectRole from the JIRA SOAP API developerRole = _JiraService.getProjectRole(_Token, (long)_DeveloperId); } return developerRole; }
欢迎评论.显然,我们可以以不同的角色使用相同的方式.只需要确保用户登录JIRA api有一些管理员权限