我不是很精通web API调用,但我一直在使用以下powershell代码(本例中的这个站点是我发现的一个具有一些公共数据的站点……我的站点是内部的,需要我通过凭证,这对我来说是有效的,没有问题):
If(-not (Get-InstalledModule -Name 'ConfluencePS')){Install-Module ConfluencePS}
Import-Module ConfluencePS
Set-ConfluenceInfo -BaseUri "https://wiki.opnfv.org"
$space = Get-confluencepage -Spacekey ds
ForEach($item in $space)
{
$splatParams = @{
Uri = "https://wiki.opnfv.org/rest/api/content/$($item.ID)/restriction"
ContentType = 'application/json'
method = 'GET'
}
#reference https://developer.atlassian.com/cloud/confluence/rest/#api-api-content-id-restriction-get
Invoke-RestMethod @splatParams
}ConfluencePS的documentation表明,限制仍然是一个开放的特性请求,但我需要让它为项目工作。
我在ConfluencePS.psm1的982行设置了一个断点,可以看到各种调用和参数是如何构造的,但是当我试图模仿它(并根据合流documentation更改URI )时,我得到了一个错误“HTTPerror405- MethodNotAllowed”。有没有人对我如何让它工作有什么建议?我正在尝试返回应用于特定空间中所有页面的权限。
发布于 2019-12-17 19:24:48
按内容ID获取限制
正如您自己发现的,需要添加"byOperation“。
我能够通过以下代码获得特定页面的限制:
# for testing purposes ONLY, I've specified the URL and ID
$wikiUrl = "https://wiki.opnfv.org"
$itemId = "6820746"
$splatParams = @{
Uri = "$wikiUrl/rest/api/content/$itemId/restriction/byOperation"
ContentType = 'application/json'
method = 'GET'
}
$result = Invoke-RestMethod @splatParams在版本6.0.4和6.15.9上测试
按用户名过滤
如果您希望按特定用户名过滤结果,则可以使用以下URI:"$wikiUrl/rest/api/content/$itemId/restriction/byOperation/.../user?userName=".
Bt,在这种操作方式上有一个开放的bug:restriction returns ambiguous responses
https://stackoverflow.com/questions/59306380
复制相似问题