尝试使用 Invoke-RestMethod 更新现有 VSTS 工作项时,我不断收到
您必须在请求正文中传递有效的补丁文档。
这是我要经过的
$Body = '[{ "op": "test", "path": "/rev", "value": 1},{ "op": "add", "path": "/fields/System.IterationPath", "value":"' + $caseIterationPath + '"},{ "op": "add", "path": "/fields/System.AreaPath", "value":"' + $caseAreaPath + '"}]'
Invoke-RestMethod -Uri "$rootUri/_apis/wit/workitems/$($case.id)?$apiVersion" -Method PATCH -ContentType application/json-patch+json -Headers @{Authorization= $authorization} -Body $Body
Run Code Online (Sandbox Code Playgroud)
身体扩展到
"[{ "op": "test", "path": "/rev", "value": 1},{ "op": "add", "path": "/fields/System.IterationPath", "value":"Foo\Bar 2016.4\2016.4.02"},{ "op": "add", "path": "/fields/System.AreaPath", "value":"Foo\Apps\Bar Stool\Eating"}]"
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激!
我正在尝试为客户创建一个 Web 应用程序(托管在 Azure 上),以便能够将工作项提交到我们的团队服务页面。基本上是一个支持票页面,所以他们不必一直打电话来解释他们的积压。
下面是我用来创建工作项的类和方法,遵循 Microsoft 的示例代码,出于隐私原因做了一些明显的更改。此方法由单击按钮触发,到目前为止我无法使用它来创建任何工作项。
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using Newtonsoft.Json;
namespace customapp
{
public class CreateWorkItem
{
public void CreateWorkItemMethod()
{
string personalAccessToken = "xxxxxxxxx";
string credentials = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "xxx", personalAccessToken)));
Object[] patchDocument = new Object[1];
patchDocument[0] = new { op = "add", path = "/fields/System.Title", value = "Test" };
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", credentials);
var patchValue = new StringContent(JsonConvert.SerializeObject(patchDocument), Encoding.UTF8, "application/json-patch+json"); …Run Code Online (Sandbox Code Playgroud) 我正在尝试按名称解析特定的 VSTS 组以检索 identityDescriptor 属性。我想利用支持的查询参数,而不是查询所有组和过滤器。查看VSTS Groups - List API,它支持附加查询参数 scopeDescriptor 和 subjectType。但是,我一直为这些参数提供错误的值。
但是,当我指定这些的任何组合时,我得到 0 个结果。此外,一旦我添加了 scopeDescriptor,我就会遇到 Microsoft.VisualStudio.Services.Graph.InvalidSubjectTypeException -> HTTP 400 Bad Request。
问题:
编辑 1 subjectTypes 不是实际类型,而是主题描述符前缀的子类型。例如 -> vssgp,aadgp:
"subjectDescriptor": "vssgp.Dc0NDgzLTzQ1NwOTI5LTI0NTcwNDLTAtMwUy0xLTktMTAtMC0wMjgxNjcxNDU0OS0zMU1MTM3NDI0NS0yMjUzNzA0ODMtE"
Run Code Online (Sandbox Code Playgroud)
示例查询网址:
- Working:
https://{account}.vssps.visualstudio.com/_apis/graph/groups?api-version=4.1-preview.1
- Working subjectTypes:
https://{account}.vssps.visualstudio.com/_apis/graph/groups?subjectTypes=vssgp&api-version=4.1-preview.1
- scopeDescriptor throws:
https://{account}.vssps.visualstudio.com/_apis/graph/groups?scopeDescriptor=collection&api-version=4.1-preview.1
https://{account}.vssps.visualstudio.com/_apis/graph/groups?scopeDescriptor=collection&subjectTypes=Microsoft.TeamFoundation.Identity&api-version=4.1-preview.1
Run Code Online (Sandbox Code Playgroud) 我是VSTS平台的新手.在我的一个项目中,我试图将bitbucket源代码控制集成到VSTS.通过这种方式,我应该能够看到bitbucket上的更新到VSTS帐户上.
我尝试过在VSTS上创建构建,但这只显示了所选的bitbucket存储库的提交历史记录.
有没有办法管理VSTS上的所有bitbucket更改作为源代码控制?
bitbucket bitbucket-api azure-devops azure-pipelines azure-devops-rest-api
我希望获得我的 VSTS 帐户下所有存储库的所有分支的列表。我能找到https://{account}.visualstudio.com/DefaultCollection/_apis/git/repositories?api-version=1.0。但是,这并没有列出我的存储库下的所有分支,它只列出了默认分支。
我有 C# 代码,
var personalaccesstoken = "TOKEN";
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(
new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
Convert.ToBase64String(
System.Text.ASCIIEncoding.ASCII.GetBytes(
string.Format("{0}:{1}", "", personalaccesstoken))));
using (HttpResponseMessage response = client.GetAsync(
"https://{account}.visualstudio.com/DefaultCollection/_apis/git/repositories?api-version=1.0").Result)
{
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
Console.ReadLine();
Run Code Online (Sandbox Code Playgroud)
谁能指出 REST API 或告诉我一种获取存储库下所有分支的方法?
我想使用 c# 代码在 VSTS 中创建/触发发布。我可以使用 VSTS REST API @ https://docs.microsoft.com/en-us/rest/api/vsts/release/releases?view=vsts-rest-4.1创建/触发它
但是我想知道是否有任何 NuGet 包可用于使用 c# 在 VSTS 中创建/触发/更新版本?
c# azure-devops azure-pipelines-release-pipeline azure-artifacts azure-devops-rest-api
ADAL.js 和 AAD v1 可以使用委派的 user_impersonation 范围访问 Azure DevOps。
我使用具有委托权限的相同 AAD 应用程序 ID 来使用 MSAL.js 生成访问令牌。令牌已成功创建,但访问令牌无法访问 Azure DevOps。
解码后的 JWT 令牌中唯一有意义的区别是“aud”声明不同。
在 ADAL/v1 中,aud 是 Azure DevOps 的应用程序 ID:
"aud": "499b84ac-1321-427f-aa17-267ca6975798"
Run Code Online (Sandbox Code Playgroud)
在 MSAL/v1 中,aud 是 Azure DevOps 的唯一 uri:
"aud": "https://app.vssps.visualstudio.com"
Run Code Online (Sandbox Code Playgroud)
有没有人能够使用具有 user_impersonation 委派权限的 MSAL.js 来访问 Azure DevOps rest API?如果是这样,是否缺少让 MSAL 工作的东西?
他们的 JWT 验证是否可能还没有考虑到第二个受众价值?
azure jwt azure-active-directory azure-ad-msal azure-devops-rest-api
因此,我看到 Api 通过其构建 ID 获取构建,但我看不到通过构建号获取它。是列出所有构建的唯一方法吗?
我是node.js“azure-devops-node-api”的新手。我想连接我的集合, getPersonalAccessTokenHandler(token) 方法工作正常,但我想使用用户名和密码进行身份验证。getNtlmHandler(用户名,密码)确实进行了身份验证,但我无法使用这种方法获取存储库。请建议我更好的身份验证方法
const azdev = require("azure-devops-node-api");
const collectionURL = 'https://dev.azure.com/username';
let authHandler = azdev.getNtlmHandler('username', 'password');
let connection = new azdev.WebApi(collectionURL, authHandler);
connection.connect().then(connData => {
console.log(`Connection established successfully!!!. This is
${connData.authenticatedUser.providerDisplayName}. Welcome!!!`);
connection.getGitApi().then(vstsGit => {
vstsGit.getRepositories('projectName').then(repos => {
// repos is null or undefined
console.log('There are', repos.length, 'repositories in this
project');
// But When I authenticates with Token, It works fine.
});
});
});
Run Code Online (Sandbox Code Playgroud) 我可以使用以下 json 主体更新构建管道中的变量
$body = '
{
"definition": {
"id": 25
},
"parameters": "{\"var\":\"value\"}"
}
'
Run Code Online (Sandbox Code Playgroud)
相同的 json 不适用于 Release pipeline 。有什么方法可以通过发布管道以相同的方式传递变量
azure-devops azure-pipelines azure-pipelines-release-pipeline azure-devops-rest-api
azure-devops ×8
azure ×2
azure-pipelines-release-pipeline ×2
c# ×2
bitbucket ×1
git ×1
jwt ×1
powershell ×1