标签: azure-devops-rest-api

如何使用 Azure DevOps Rest API 启动版本中的特定阶段

我利用这个API 来创建一个版本。

但请求正文中似乎没有属性可以指定要发布的某个阶段?

我还有其他方法可以做到吗?

azure-devops azure-pipelines azure-devops-rest-api

2
推荐指数
1
解决办法
1829
查看次数

使用 REST API 将构建链接添加到工作项

我有一个由另一个构建触发的构建。触发构建具有与其链接的工作项。为了获得更好的可见性,我想将链接到触发构建的所有工作项也链接到触发的构建。我已经准备好拉取工作项列表的所有内容,但找不到使用 REST API 将工作项链接到构建的方法尝试使用工作项 - 更新添加链接选项 https://learn。 microsoft.com/en-us/rest/api/azure/devops/wit/work%20items/update?view=azure-devops-rest-5.1#add-a-link

工作项关系类型 - 列表返回: https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/work%20item%20relation%20types/list ?view=azure-devops-rest -5.1

System.LinkTypes.Remote.Dependency-Forward
System.LinkTypes.Remote.Dependency-Reverse
System.LinkTypes.Duplicate-Forward
System.LinkTypes.Duplicate-Reverse
Microsoft.VSTS.TestCase.SharedParameterReferencedBy-Forward
Microsoft.VSTS.TestCase.SharedParameterReferencedBy-Reverse
Microsoft.VSTS.Common.Affects-Forward
Microsoft.VSTS.Common.Affects-Reverse
Microsoft.VSTS.TestCase.SharedStepReferencedBy-Forward
Microsoft.VSTS.TestCase.SharedStepReferencedBy-Reverse
Microsoft.VSTS.Common.TestedBy-Forward
Microsoft.VSTS.Common.TestedBy-Reverse
System.LinkTypes.Dependency-Forward
System.LinkTypes.Dependency-Reverse
System.LinkTypes.Hierarchy-Forward
System.LinkTypes.Hierarchy-Reverse
System.LinkTypes.Related
System.LinkTypes.Remote.Related
AttachedFile
Hyperlink
ArtifactLink
Run Code Online (Sandbox Code Playgroud)

除了最后三个,似乎都是 WI 与 WI 的关系。如何添加构建链接?

azure-devops-rest-api

2
推荐指数
1
解决办法
2769
查看次数

如何从 Azure DevOps Server 调用用户图形 API

以下内容适用于 Azure DevOps 服务(云):

curl ... https://vssps.dev.azure.com/acme/_apis/graph/users
Run Code Online (Sandbox Code Playgroud)

但是,对于我的本地安装,以下所有选项均收到 404 错误:

curl ... https://tfs.acme.com/_apis/graph/users
curl ... https://vssps.tfs.acme.com/_apis/graph/users
curl ... https://tfs.acme.com/test-collection/_apis/graph/users
Run Code Online (Sandbox Code Playgroud)

我知道这不是凭据问题,因为我成功地进行了其他 api 调用。

我找不到任何本地文档。云版本:https://learn.microsoft.com/en-us/rest/api/azure/devops/graph/users/list ?view=azure-devops-rest-5.1

tfs azure-devops azure-devops-rest-api azure-devops-server azure-devops-server-2019

2
推荐指数
1
解决办法
1019
查看次数

通过 Azure DevOps Services Rest Api 完成的 Pull 请求的列表

尝试使用 Azure DevOps Services Rest Api

https://learn.microsoft.com/en-us/rest/api/azure/devops/?view=azure-devops-rest-5.1

任何人都可以建议调用正确的 API 来获取存储库的已完成拉取请求列表

我一直在研究 Git Api,但似乎特定的 API 只返回尚未完成的 PR。

c# azure-devops azure-devops-rest-api

2
推荐指数
1
解决办法
3443
查看次数

使用 REST API 添加/删除管道检查

我需要在 azure DevOps 管道环境中动态添加/删除或启用禁用批准和检查。有没有这个的rest api?

在此输入图像描述

azure-devops azure-pipelines azure-devops-rest-api

2
推荐指数
1
解决办法
1500
查看次数

使用 Azure DevOps REST API 将新文件和文件夹添加到 Azure Git 存储库

如何使用 Azure DevOps REST API 将新文件和文件夹添加到 Azure Git 存储库?

我想使用 Azure DevOps REST API 将一些静态文件添加到我的存储库。

https://learn.microsoft.com/en-us/rest/api/azure/devops/git/repositories?view=azure-devops-rest-5.1

是否有通过 REST API 提供的任何选项?

或者任何其他可用的自动化方式,无论是 CICD 还是通过 c#?

azure-devops azure-devops-rest-api

2
推荐指数
1
解决办法
8739
查看次数

PowerShell 脚本中的 Azure DevOps REST API 顶部参数不起作用

我有以下脚本用于从 Azure DevOps 项目生成发布报告。

$token="**************************************************************"

$url="https://dev.azure.com/{orgnization}/_apis/projects?api-version=6.0"

$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))



$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token"} -Method Get -ContentType application/json

Foreach($projectName in $response.value.name)
{
  
  $url1="https://vsrm.dev.azure.com/{orgnization}/$($projectname)/_apis/release/releases?api-version=6.0"
 
  $response = Invoke-RestMethod -Uri $url1 -Headers @{Authorization = "Basic $token"} -Method Get -ContentType application/json-patch

  
   echo $response | ConvertTo-Json -Depth 99 |  Out-File "D:\\file.json" -Append

}
Run Code Online (Sandbox Code Playgroud)

在此脚本中,第一个 API 仅返回 100 条记录。当我尝试添加顶部参数以返回更多记录(如下所示)时,它不会返回任何内容。我在这里做错了什么吗?

https://dev.azure.com/uniperteamservices/_apis/projects?api-version=6.0&$top=500
Run Code Online (Sandbox Code Playgroud)

您能否建议我如何在 REST API url 中添加可在上面的 PowerShell 脚本中运行的 top 参数?

rest powershell azure-powershell azure-devops azure-devops-rest-api

2
推荐指数
1
解决办法
1802
查看次数

Azure DevOps OAuth2. TF400813: The user is not authorized to access this resource

I have implemented an OAuth2 app for Azure DevOps. My website takes user (User A) to authorize the app using the below URL. Step1

https://app.vssps.visualstudio.com/oauth2/authorize?scope=vso.code_full (skipped the other parameters) 
Run Code Online (Sandbox Code Playgroud)

The above URL works fine and returns with a code+userInfo after user authorization. Now I get an access token passing the code returned from the app using the below API call.

https://app.vssps.visualstudio.com/oauth2/token
Run Code Online (Sandbox Code Playgroud)

I can further fetch all the organizations associated with user's (User A ) account using the below API call …

oauth-2.0 azure-devops azure-devops-rest-api

2
推荐指数
1
解决办法
2158
查看次数

用于GIT分支创建的VSTS REST refs API

根据MS文档,VSTS的“ refs” API应该允许您从特定提交中创建一个新分支,但我似乎无法使其正常工作。这是我拥有的POC代码(在PowerShell中):

$uri = 'https://{account}.visualstudio.com/{project}/_apis/git/repositories/{repository}/refs?api-version=1.0';

[array]$requestList = @();
$requestObj = New-Object -TypeName psobject;
$requestObj | Add-Member -MemberType NoteProperty -Name "name" -Value 'refs/heads/api-branch1';
$requestObj | Add-Member -MemberType NoteProperty -Name "oldObjectId" -Value "0000000000000000000000000000000000000000";
$requestObj | Add-Member -MemberType NoteProperty -Name "newObjectId" -Value "272c5f931889e5c6cc61a6fdb19ad00eeebf2d77";
$requestList += @($requestObj);

$header = Get-AuthHeader;
$body = ConvertTo-Json -InputObject @($requestList);
Write-Host $body;

$response = Invoke-RestMethod -Uri $uri -Headers $header -Method Post -Body $body -ContentType application/json;

Write-Host $response;
Run Code Online (Sandbox Code Playgroud)

如Write-Host语句所报告,请求正文的格式正确,并且我已验证newObjectId是正确的提交ID。但是,当我运行脚本时,出现以下错误:

Invoke-RestMethod : {"$id":"1","innerException":null,"message":"Value cannot be null.\r\nParameter name: refUpdates","typeName":"System.ArgumentNullException, mscorlib, Version=14.0.0.0, …
Run Code Online (Sandbox Code Playgroud)

azure-devops-rest-api

1
推荐指数
1
解决办法
1692
查看次数

Azure REST API 获取分支返回 0 个分支

我正在尝试获取一个项目的所有分支

https://dev.azure.com/$organization/$project/_apis/tfvc/branches?&api- 
version=5.0
Run Code Online (Sandbox Code Playgroud)

我在其他有效的查询中使用凭据、组织和项目变量。请求格式基于此处的示例

https://docs.microsoft.com/en-us/rest/api/azure/devops/tfvc/branches/get?view=azure-devops-rest-5.0

我得到的回应是

count value
----- -----
    0 {} 
Run Code Online (Sandbox Code Playgroud)

当存储库中有许多分支时。

我应该在某处指定存储库吗?或者还有什么?谢谢!

azure azure-devops azure-devops-rest-api

1
推荐指数
1
解决办法
918
查看次数