【发布时间】:2021-03-29 20:43:55
【问题描述】:
我正在尝试使用 REST API 创建一个静态测试套件,但我的响应中出现错误。
我的请求正文
$body= @"
[ {
"suiteType": "StaticTestSuite",
"name": "NewTestSuite",
"area": {
"name": "<TeamName>"
},
"iteration": "<Iteration>"
}
]"@
$BuildReqBodyJson = $body | ConvertTo-Json
$response = Invoke-RestMethod -Uri $Uri -Method POST -Headers $header -ContentType "application/json" -Body $BuildReqBodyJson
错误:
Invoke-RestMethod : {"$id":"1","innerException":null,"message":"Value cannot be null.\r\nParameter name:
testSuite","typeName":"System.ArgumentNullException, mscorlib","typeKey":"ArgumentNullException","errorCode":0,"eventId":0}
At
+ $response = Invoke-RestMethod -Uri $Uri -Method POST -Headers $heade ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
【问题讨论】:
-
您正在传递一个数组。根据文档,它不应该是一个数组。
-
我尝试删除正文中的 [] 标签,仍然是同样的错误。 {"$id":"1","innerException":null,"message":"值不能为空。\r\n参数名称:testSuite","typeName":"System.ArgumentNullException, mscorlib","typeKey" :"ArgumentNullException","errorCode":0,"eventId":0}
标签: azure-devops azure-devops-rest-api