0
在the docs尋找這個REST URI應該是正確的:嘗試使用匯合API獲取(哎呀,你已經找到了一個死鏈接。)
https://tenant.atlassian.net/rest/api/content/search?cql=space=myspace
爲什麼我瀏覽到該URL中鉻(在登錄後)我得到一個死鏈接。 當我嘗試下面的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
也許用戶名包含一個非ASCII碼符號?應該是'UTF8.GetBytes'另外,[文檔](https://docs.atlassian.com/confluence/REST/latest)根據用法列出了幾個不同的URL路徑。 – wOxxOm