我们重复了下面提到的相同步骤。 Update VSTS test case status to PASS / FAIL using rest api
但是,我们得到的是401或404或203响应代码。您能帮我们吗?
使用VSTS Webtest的方法
https:// {组织代码} .visualstudio.com / {项目代码} / _ api / _testManagement / BulkMarkTestPoints?api-version = 5.1-preview.1
有效载荷:
{
planId: 187830,
suiteId: 187831,
testPointIds: [88212],
outcome: 2
}
Headers:
Referer=https://{Organisation Code}.visualstudio.com/{ProjectName}/_testManagement
accept=application/json
accept-language=en-US
Authorization=Basic {PAT}
Host={Organisation Code}.visualstudio.com
content-type=application/json
响应:
HTTP/1.1 401 Unauthorized
Pragma : no-cache
Content-Length : 307
Content-Type : application/json; charset=utf-8
Expires : -1
方法2:使用POSTMAN
https://{Organisation Code}.visualstudio.com/{Project Code}/_api/_testManagement/BulkMarkTestPoints?api-version=5.1-preview.1
有效载荷:
{
planId: 187830,
suiteId: 187831,
testPointIds: [88212],
outcome: 2
}
Headers:
Referer=https://{Organisation Code}.visualstudio.com/{ProjectName}/_testManagement
accept=application/json
accept-language=en-US
Authorization=Basic {PAT}
Host={Organisation Code}.visualstudio.com
content-type=application/json
注意:我们已将凭据授予为基本身份验证,并且遇到相同的错误。
HTTP/1.1 401 Unauthorized
Pragma : no-cache
Content-Length : 307
Content-Type : application/json; charset=utf-8
Expires : -1
答案 0 :(得分:0)
您在上述线程中提到的步骤似乎不包含身份验证。您可以在powershell脚本中参考以下完整示例。
$url = "xxxxxxxxxxxx" # Request url
$connectionToken="xxxxxxxxxxxxxxxxxxxxxxxxx" # personal access token
$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($connectionToken)"))
$pipeline = Invoke-RestMethod -Uri $url -Headers @{authorization = "Basic $base64AuthInfo"} -Method Get
要获取您的个人访问令牌,可以检查步骤here。