azure-devops - 使用 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''"
}
有关详细信息,请参阅文档中的示例。
推荐阅读
- c++ - 在调用 MPI_Init() 之前获取 MPI 线程数
- azure-devops - 防止在 VSTS 上发布公共包
- c++ - 用特征初始化向量C++的矩阵
- java - BeanCreationException:创建名为“userRepository”的 bean 时出错:合并 bean 定义的后处理失败
- c++ - c++非法指令(核心转储)
- javascript - BIRT:parseInt 的奇怪行为
- sublimetext3 - 如何在 Sublime Text 3 中禁用多个光标实例?
- python - Keras 分类器为手势分类提供了荒谬的准确性
- php - PHP DateTime 差异返回错误的天数
- java - httpclient 默认接受不受信任的证书