VSTS Rest API从变更集API返回特定项

VSTS Rest API从变更集API返回特定项,rest,azure-devops,changeset,tfvc,azure-devops-rest-api,Rest,Azure Devops,Changeset,Tfvc,Azure Devops Rest Api,我调用RESTAPI来返回从特定变更集中更改的所有文件,我真正想要做的是返回具有已知路径的特定项的URL属性 所以我现在有了变更集API调用 https://someplace.visualstudio.com/_apis/tfvc/changesets/19483/changes 这个回报有点像 { "count": 10, "value": [ { "item": { "version": 19483, "size": 882,

我调用RESTAPI来返回从特定变更集中更改的所有文件,我真正想要做的是返回具有已知路径的特定项的URL属性

所以我现在有了变更集API调用

https://someplace.visualstudio.com/_apis/tfvc/changesets/19483/changes
这个回报有点像

{
  "count": 10,
  "value": [
    {
      "item": {
        "version": 19483,
        "size": 882,
        "hashValue": "ACWU0KSlO+jbsSJB5IwU4Q==",
        "path": "$/WaveDatabases/MasterData/Custom Scripts/2017-07-17-120218 28 user/MigrationScript.sql",
        "url": "https://someplace.visualstudio.com/_apis/tfvc/items/$/WaveDatabases/MasterData/Custom%20Scripts/2017-07-17-120218%2028%20user/MigrationScript.sql?versionType=Changeset&version=19483"
      },
      "changeType": "add, edit, encoding"
    },
    {
      "item": {
        "version": 19483,
        "size": 55,
        "hashValue": "Wur9rYW/rRYcvRWoVUZO7A==",
        "path": "$/WaveDatabases/MasterData/Custom Scripts/2017-07-17-120218 28 user/ReadonlyMetadata.json",
        "url": "https://someplace.visualstudio.com/_apis/tfvc/items/$/WaveDatabases/MasterData/Custom%20Scripts/2017-07-17-120218%2028%20user/ReadonlyMetadata.json?versionType=Changeset&version=19483"
      },
      "changeType": "add, edit, encoding"
    },
    {
      "item": {
        "version": 19483,
        "size": 379,
        "hashValue": "vHCQymsTXiZVuLMpeoShNg==",
        "path": "$/WaveDatabases/MasterData/Tables/Cust.test.sql",
        "url": "https://someplace.visualstudio.com/_apis/tfvc/items/$/WaveDatabases/MasterData/Tables/Cust.test.sql?versionType=Changeset&version=19483"
      },
      "changeType": "edit"
    }
  ]
}
这将返回该变更集中所有文件的数组。我知道在这个变更集中,在某个未知文件夹下总会有一个名为MigrationScript.sql的文件。我想做的是找到一种方法,只返回数组中包含MigrationScript.sql的1个元素。另外,我只想返回该1元素的url属性


这需要通过URL来完成,因为想要使用它的工具我无法编写代码来解析结果。

您无法直接通过变更集REST API URL来完成

您可以使用RESTAPI构建一个web API应用程序来检索数据,然后返回所需的相应数据,然后可以在该工具中指定web API URL

简单代码(使用)

var u=新Uri(“https://starain.visualstudio.com");
VssCredentials c=新的VssCredentials(新的Microsoft.VisualStudio.Services.Common.VSSBasiccredentials(string.Empty,“[personal access token]”);
var连接=新VSS连接(u,c);
var tfvcClient=connection.GetClient();
var changes=tfvcClient.GetChangesetChangesAsync(id:1130);
foreach(var currentChange in changes.Where(ci=>ci.Item.Path.EndsWith(“UnitTest1.cs”))
{
字符串url=currentChange.Item.url;
}
var u = new Uri("https://starain.visualstudio.com");
     VssCredentials c = new VssCredentials(new Microsoft.VisualStudio.Services.Common.VssBasicCredential(string.Empty, "[personal access token]"));           
 var connection = new VssConnection(u, c);
            var tfvcClient = connection.GetClient<TfvcHttpClient>();
           var changes= tfvcClient.GetChangesetChangesAsync(id: 1130).Result;
            foreach(var currentChange in changes.Where(ci=>ci.Item.Path.EndsWith("UnitTest1.cs")))
            {
                string url = currentChange.Item.Url;
            }