使用 Azure Devops REST 创建静态测试套件时出错 API
Error in creating static Test suites using Azure Devops REST API
我正在尝试使用 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
您的请求正文似乎有误。根据文档,请求正文中没有 area
或 iteration
属性。
请参阅下面的示例请求正文以创建静态测试套件。
$body='
{
"suiteType": "StaticTestSuite",
"name": "NewTestSuite"
}
'
如果要基于查询创建测试套件,可以指定 queryString
属性。请参阅下面的示例。
$body='
{
"suiteType": "DynamicTestSuite",
"name": "allTestSuite",
"queryString": "SELECT [System.Id],[System.WorkItemType] FROM WorkItems WHERE [System.WorkItemType] IN GROUP ''Microsoft.TestCaseCategory'' AND [System.AreaPath]=''myareapath'' AND [System.IterationPath] = ''myiterationpath''"
}
有关详细信息,请参阅 examples in the document。
我正在尝试使用 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
您的请求正文似乎有误。根据文档,请求正文中没有 area
或 iteration
属性。
请参阅下面的示例请求正文以创建静态测试套件。
$body='
{
"suiteType": "StaticTestSuite",
"name": "NewTestSuite"
}
'
如果要基于查询创建测试套件,可以指定 queryString
属性。请参阅下面的示例。
$body='
{
"suiteType": "DynamicTestSuite",
"name": "allTestSuite",
"queryString": "SELECT [System.Id],[System.WorkItemType] FROM WorkItems WHERE [System.WorkItemType] IN GROUP ''Microsoft.TestCaseCategory'' AND [System.AreaPath]=''myareapath'' AND [System.IterationPath] = ''myiterationpath''"
}
有关详细信息,请参阅 examples in the document。