简体   繁体   English

尝试使用 azure 测试计划 api 从电源 shell 脚本在测试套件中添加测试人员名称

[英]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.

相关问题 尝试使用Power Shell脚本测试网站的可用性 - Trying to Use Power shell Script to test availability of website 作为流水线自动化测试的一部分,有没有办法为每个测试用例使用 Azure DevOps 测试计划参数? - Is there a way to use Azure DevOps Test Plan parameters for each test case as part of automate testing from pipeline? 我正在尝试将本地电源shell用作云电源Z2591C98B70119FE624898B1E424B54B5E9111111111111C98B7011C98B70198B70198B701598B7254B1598B4B4BB724B154B4B4BB798B14B14B14B14B4BB14B14B4BB14B14B4BB14B14B4BB14B14B14B14B14B14B14B14B14B14B11ER - i am trying to use local power shell as cloud power shell (azure power shell vs local power shell ) 在Azure中运行Power Shell脚本 - Running a power shell script in Azure 示例Power-Shell脚本以从REST API读取值 - sample power-shell script to read values from REST API 尝试通过 Power Shell 脚本在 IIS 中创建网站 - Trying to create a website in IIS by Power Shell script Power Shell测试连接然后获取计算机名称或mac-addr - Power Shell test-connection and then get computers name or mac-addr power shell中的-eq关键字测试引用相等还是使用Object.Equals() - Does -eq keyword in power shell test reference equality or use Object.Equals() 使用 powershell 将 Azure 测试计划克隆到新区域路径 - Clone Azure Test Plan to new area path using powershell 从另一个Power Shell脚本获得回报 - get return from another power shell script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM