我正在尝试从JIRA REST API获取所有用户。我需要将所有用户从我自己的 java 客户端保存到我的数据库中。 有可能这样做吗?
如果是这样,我们将如何做到这一点?
我正在尝试从JIRA REST API获取所有用户。我需要将所有用户从我自己的 java 客户端保存到我的数据库中。 有可能这样做吗?
如果是这样,我们将如何做到这一点?
似乎有一种无证的方式:
使用“查找用户”api
https://docs.atlassian.com/jira/REST/latest/#api/2/user-findUsers
对于用户名查询使用 %
例如:/rest/api/2/user/search?username=%
您可以获得可分配给特定项目的所有用户。如果每个人都是可分配的,您将获得所有用户。
/rest/api/2/user/assignable/search?project=PROJECT
卷曲:
curl -D -u USERNAME:PASSWORD -X GET -H "Content-Type: application/json" https://company.atlassian.net/rest/api/2/user/assignable/search?project=PROJECT
获取 JIRA 实例中所有用户的一种可能方法是使用 Crowd API 的/rest/usermanagement/1/search
端点:
curl -X GET \
'https://jira.url/rest/usermanagement/1/search?entity-type=user&start-index=0&max-results=1000&expand=user' \
-H 'Accept: application/json' -u username:password
请注意,您需要创建一个新的JIRA 用户服务器条目来创建 Crowd 凭据(username:password
上面的参数),以便您的应用程序在其 REST API 调用中使用:
这对我有用:
https://company_name.altassian.net/rest/api/3/users/search?
它将返回如下内容:
[
{
"accountId": "id",
"accountType": "app",
"avatarUrls": {},
"displayName": "Slack",
"active": true
},
{
"self": "profile_link of ther user",
"accountId": "id",
"accountType": "atlassian",
"avatarUrls": {},
"displayName": "**Real user**",
"active": true,
"locale": "en_US"
}
]
在保存到数据库之前,您必须检查accountType
:
if (accountType == 'altassian') {
then do push; // or whatever
}
在 Jira Rest API 中没有直接获取所有用户的方法。如果您的用户很容易在 Jira 应用程序中分组,您可能必须使用搜索功能(这需要传递至少一个字母来搜索)或组功能。
浏览他们的文档以获得更好的参考。
https://docs.atlassian.com/jira/REST/latest/#d2e2
https://docs.atlassian.com/jira/REST/latest/#d2e808
您可以使用简单的 JDBC 脚本和一些高级脚本,通过您的 java 客户端将用户列表写入数据库。
希望这可以帮助!
我知道这是一个旧线程,但如果有人现在正在搜索这个,这对我有用:
GET /rest/api/latest/user/search?query=+&maxResults=1000
谢谢 ;)
目前:
对于 Jira 云:
获取所有(活动 + 非活动)用户:
GET /rest/api/2/users/search?query
获取所有活跃用户:
GET /rest/api/2/user/search?query
对于 Jira 服务器:
获取所有(活动 + 非活动)用户:
GET /rest/api/2/user/search?username=.&includeInactive=true
获取所有活跃用户:
GET /rest/api/2/user/search?username=.
我也被这个问题困扰了很长时间。我按用户完成的项目任务搜索任务。答案: https ://developer.atlassian.com/rest/api/2/search? jql = project = yourProject + AND + status = done + AND + assignee= yourUser