gpt4 book ai didi

Azure DevOps PS REST API : No api-version was supplied for the \"PUT\" request. 该版本必须作为 Accept header 的一部分提供

转载 作者:行者123 更新时间:2023-12-03 02:14:24 35 4
gpt4 key购买 nike

我正在尝试运行以下脚本以在 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":Noapi-version was supplied for the "PUT" request. The version must besupplied either as part of the Accept header (e.g. "application/json;api-version=1.0") or as a query parameter (e.g."?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输出值进行检查,确保其值正确,以&api-version=5.0结尾且内部没有特殊字符,因为您在这里使用变量,例如:PullRequestTitle。

关于Azure DevOps PS REST API : No api-version was supplied for the \"PUT\" request. 该版本必须作为 Accept header 的一部分提供,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71950542/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com