簡體   English   中英

Azure DevOps PS REST API:沒有為“PUT”請求提供 api 版本。 該版本必須作為接受的一部分提供 header

[英]Azure DevOps PS REST API : No api-version was supplied for the \"PUT\" request. The version must be supplied either as part of the Accept header

我正在嘗試運行以下腳本以在 Azure DevOps wiki 頁面中創建和添加數據:

$JSONBody= @{
   "Content"="PR# $PullRequestId : $PullRequestTitle `n `n WorkItem# $workItemId : $taskTitle `n `n Iteration: $taskIterationPath `n `n Tags: $taskTags `n `n Description: `n `n $taskDescription" 
}

$wikiuri="https://dev.azure.com/{org_name}/{proj_name}/_apis/wiki/wikis/{wiki-proj-name}.wiki/pages?path=Release Notes/$todayDate/PR-$PullRequestId-$PullRequestTitle-$(RELEASE.ATTEMPTNUMBER)&api-version=5.0"

$Response=Invoke-RestMethod -Uri $wikiuri `
                            -Method PUT `
                            -Body ($JSONBody|ConvertTo-Json) `
                            -ContentType "application/json" `
                            -Headers @{Authorization=("Basic {0}" -f $Base64AuthInfo)}

上面的腳本過去工作得很好。 但是從上周左右開始,它開始拋出以下錯誤:

Invoke-RestMethod: {"$id":"1","innerException":null,"message": 沒有為“PUT”請求提供 api 版本。 該版本必須作為 Accept header 的一部分(例如“application/json; api-version=1.0”)或作為查詢參數(例如“?api-version=1.0”)提供。 “typeName”:“Microsoft.VisualStudio.Services.WebApi.VssVersionNotSpecifiedException,Microsoft.VisualStudio.Services.WebApi”,“typeKey”:“VssVersionNotSpecifiedException”,“errorCode”:0

你能幫我解決這個問題嗎?

提前致謝

錯誤發生在您的$wikiuri字符串上。 使用+組合&api-version=5.0 示例如下:

$wikiuri="https://dev.azure.com/{org_name}/{proj_name}/_apis/wiki/wikis/{wiki-proj-name}.wiki/pages?path=Release Notes/$todayDate/PR-$PullRequestId-$PullRequestTitle-$(RELEASE.ATTEMPTNUMBER)" + "&api-version=5.0"

建議Write-Host $wikiuri到 output 檢查的值,確保它有正確的值,以&api-version=5.0結尾並且里面沒有特殊字符,因為你在這里使用變量,例如:PullRequestTitle。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM