[英]Trying to use a azure Test Plan api to add tester name in Test suite from power shell script
$UpdateTesterNameUri = "https://dev.azure.com/MyOrg/MyProj/_apis/test/Plans/" + $Id + "/Suites/121221/points/" + $node + "?api-version=6.0"
Write-Output $UpdateTesterNameUri
$testerNameBody =
@{
tester = @{
"displayName" = "Veeresh Kokkalla "
}
}
$testerName = $testerNameBody | ConvertTo-Json
Invoke-RestMethod -Uri $UpdateTesterNameUri -Headers $headers -Method Patch -Body $testerName -ContentType 'application/json'
Getting following issue收到以下问题
Invoke-RestMethod : {"$id":"1","innerException":null,"message":"Value cannot be null.\r\nParameter name: tester","typeName":"System.ArgumentNullException,
mscorlib","typeKey":"ArgumentNullException","errorCode":0,"eventId":0}
At C:\Users\v-vkokkalla\Downloads\ReleaseTrain - Dailymveeresh.ps1:173 char:13
+ Invoke-RestMethod -Uri $UpdateTesterNameUri -Headers $hea ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
When I put debug it shows tester has values.当我进行调试时,它显示测试器具有值。
From your PowerShell sample, you need to define the userID in the request body.从您的 PowerShell 示例中,您需要在请求正文中定义用户 ID。 Then you can update the tester of the test point.然后您可以更新测试点的测试仪。
Here is an PowerShell example:这是一个 PowerShell 示例:
$token = "PAT"
$url="https://dev.azure.com/org/project/_apis/testplan/Plans/TestPlanID/Suites/TestSuiteID/TestPoint?includePointDetails=true&returnIdentityRef=true&api-version=6.0"
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))
$JSON = @"
[
{
"id":Testpointid,
"tester":
{
"id":"userid",
"displayName":"xx"
}
}
]
"@
$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token"} -Method Patch -ContentType application/json -Body $JSON
Write-Host "$response"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.