【发布时间】:2017-03-18 09:18:51
【问题描述】:
我正在尝试从我们的 Atlassian Confluence/Jira 实例中提取用户列表。但是,我很难找到有关可用 REST 服务的良好文档,而且似乎不推荐使用 SOAP 服务。
下面的代码确实有结果,但是我们有超过 100 个用户,这返回 0。
if(-not ($credentials)) { #put this here so I can rerun the same script in the same IDE session without having to reinput credentials each time
$credentials = get-credential 'myAtlassianUsername'
}
$tenant = 'myCompany'
invoke-restmethod -Method Get -Uri ('https://{0}.atlassian.net/rest/api/2/groupuserpicker?query=users' -f $tenant) -Credential $credentials | ConvertTo-Json -Depth 5
(ConvertTo-Json 只是为了更容易查看扩展的结果集)。
{
"users": {
"users": [
],
"total": 0,
"header": "Showing 0 of 0 matching users"
},
"groups": {
"header": "Showing 2 of 2 matching groups",
"total": 2,
"groups": [
{
"name": "confluence-users",
"html": "confluence-\u003cb\u003eusers\u003c/b\u003e",
"labels": [
]
},
{
"name": "jira-users",
"html": "jira-\u003cb\u003eusers\u003c/b\u003e",
"labels": [
]
}
]
}
}
我认为结果试图为我提供 JIRA 和 Confluence 用户 API 的 URL;但我无法弄清楚这些相对 URL 是如何映射到根 URL 的(我尝试在 URL 的不同位置附加,所有这些都给我一个 404 或 dead link 错误)。
【问题讨论】:
-
根据 Atlassian(用于 Confluence):自 v5.5 起已弃用 XML-RPC 和 SOAP API,但是:在 confluence REST API 有足够的覆盖范围之前,不会删除 XML-RPC,我们已弃用 XML-RPC 以指示应编写新代码以尽可能使用 rest api。在增量开发 REST API 时,您仍然可以使用 RPC。但是,列出所有用户的调用在 SOAP 或 REST API 中不可用。在我们这边,我们开发了自己的插件来公开这个功能。
标签: jira powershell-4.0 jira-rest-api confluence-rest-api