无法通过Powershell脚本删除Azure Devops中的测试用例 [英] not able to delete test cases in azure devops through powershell scripts

查看:51
本文介绍了无法通过Powershell脚本删除Azure Devops中的测试用例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经检查了

即使尝试使用新的api版本,也会出现相同的错误-

  $ url ="https://dev.azure.com/testarulmouzhie/testDemo_Project/_apis/test/testcases/21?api-version=5.1-preview.1"Invoke-RestMethod -Uri $ url -Method Delete -ContentType application/json 

为ref-附加了错误-

  Invoke-RestMethod:Azure开发运营服务状态支持@AzureDevOps在第1行:char:1+ Invoke-RestMethod -Uri $ url -Method Delete -ContentType application/json+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo:InvalidOperation:(System.Net.HttpWebRequest:HttpWebRequest)[Invoke-RestMethod],WebExc肽+ FullyQualifiedErrorId:WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand 

有人可以帮助解决这个问题吗?预先感谢.

对于ref,无论如何,简单的GET rest api调用都可以正常工作.我已经尝试过低于1的那些,并且一切正常.

  $ AzureDevOpsPAT ="a2wzly2bsirXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"$ OrganizationName ="testarulmouzhie"$ AzureDevOpsAuthenicationHeader = @ {Authorization ='Basic'+ [Convert] :: ToBase64String([Text.Encoding] :: ASCII.GetBytes(:$($($ AzureDevOpsPAT)"))}}$ UriOrga ="https://dev.azure.com/$($OrganizationName)/"$ uriAccount = $ UriOrga +"_apis/projects?api-version = 5.1"Invoke-RestMethod -Uri $ uriAccount -Method get -Headers $ AzureDevOpsAuthenicationHeader 

即使使用了提琴手并尝试捕获错误日志,也附有错误日志

解决方案

啊,我认为您错过了 delete 调用API

中的autorization标头

请添加如下所示的 -Headers $ AzureDevOpsAuthenicationHeader

 -在pat访问令牌下方给出$ AzureDevOpsPAT ="ukcvd42u5rXXXXXXXXXXXXXXXXXXX";$ AzureDevOpsAuthenicationHeader = @ {Authorization ='Basic'+ [Convert] :: ToBase64String([Text.Encoding] :: ASCII.GetBytes(:$($ A $($ AzureDevOpsPAT)")));};$ url ="https://dev.azure.com/testarulmouzhie/testDemo_Project/_apis/test/testcases/21?api-version=5.0-preview.1"Invoke-RestMethod -Uri $ url -Method Delete -ContentType application/json -Headers $ AzureDevOpsAuthenicationHeader; 

正如Leo建议的那样,也可能带有许可证,那么如何检查测试用例的许可证?

I have checked How to delete multiple test cases in Azure DevOps

It not works for me.

Using PowerShell scripts alone, I want to delete multiple test cases in one go in Azure DevOps. Currently, portal only allows to delete one at a time.

I have tried like below way, and throws exceptions.

$url = "https://dev.azure.com/testarulmouzhie/testDemo_Project/_apis/test/testcases/21?api-version=5.0-preview.1"
Invoke-RestMethod -Uri $url -Method Delete -ContentType application/json

it throws error like below one-

Even tried with the new api version, same error comes-

$url = "https://dev.azure.com/testarulmouzhie/testDemo_Project/_apis/test/testcases/21?api-version=5.1-preview.1"
Invoke-RestMethod -Uri $url -Method Delete -ContentType application/json

Attached the error for ref-

Invoke-RestMethod :
Azure DevOps
Service Status Support @AzureDevOps
At line:1 char:1
+ Invoke-RestMethod -Uri $url -Method Delete -ContentType application/json
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
   eption
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Can anyone help to solve this? Thanks in advance.

For ref, anyway simple GET rest api calls works fine. i have tried below one and those are working fine.

$AzureDevOpsPAT = "a2wzly2bsirXXXXXXXXXXXXXXXXXXXXXXXXXXX"
$OrganizationName = "testarulmouzhie"

$AzureDevOpsAuthenicationHeader = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$($AzureDevOpsPAT)")) }

$UriOrga = "https://dev.azure.com/$($OrganizationName)/" 
$uriAccount = $UriOrga + "_apis/projects?api-version=5.1"

Invoke-RestMethod -Uri $uriAccount -Method get -Headers $AzureDevOpsAuthenicationHeader

Even used fiddler and tried to capture error logs- attached those too

解决方案

Ah I think you have missed your the autorizationheader in your delete Invoke API

Please include the -Headers $AzureDevOpsAuthenicationHeader like below

--give below your pat access token

$AzureDevOpsPAT = "ukcvd42u5rXXXXXXXXXXXXXXXXXXX";
$AzureDevOpsAuthenicationHeader = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$($AzureDevOpsPAT)")) };
$url = "https://dev.azure.com/testarulmouzhie/testDemo_Project/_apis/test/testcases/21?api-version=5.0-preview.1"
Invoke-RestMethod -Uri $url -Method Delete -ContentType application/json -Headers $AzureDevOpsAuthenicationHeader;

As Leo suggested it also maybe with the license, so how to check your license for the test cases?

这篇关于无法通过Powershell脚本删除Azure Devops中的测试用例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆