尝试使用 confluence API 获取(糟糕,你发现了一个死的 link。)

Trying to use confluence API getting (Oops, you've found a dead link.)

查看 the docs 这个 REST URI 应该是正确的:

https://tenant.atlassian.net/rest/api/content/search?cql=space=myspace

为什么我在 chrome 中浏览到这个 URL(登录后)我快死了 link。 当我尝试以下 powershell 脚本时,我在响应正文中遇到相同的错误:

#Connection settings
$restcreds = [System.Convert]::ToBase64String(
[System.Text.Encoding]::ASCII.GetBytes(('username' + ":" + 'pass123'))
)
$URI = 'http://tenant.atlassian.net/rest/api/content/search?cql=space=Myspace'
$httpheader = @{Authorization = "Basic $restcreds"}
$restParameters = @{
Uri = ($URI);
ContentType = "application/json";
Method = 'GET';
Headers = $httpheader;
}
$response = Invoke-RestMethod @restParameters
try{
$response = Invoke-RestMethod @restParameters
} catch {
$result = $_.Exception.Response.GetResponseStream()
$reader = New-Object System.IO.StreamReader($result)
$reader.BaseStream.Position = 0
$reader.DiscardBufferedData()
$errorResponse = $reader.ReadToEnd();
$errorResponse
}
$response

不行,你的URL无效,需要在你的URL中加上"wiki":https://tenant.atlassian.net/wiki/rest/api/content/search?cql=space=myspace