Visual Studio Team Services:使用 RestSharp 和 JSON.NET 获取所有工作项



我正在尝试从Visual Studio Team Services(Visual Studio Online)获取所有工作项。我已经能够从我的应用程序创建它们,但在找到所有这些它们时遇到问题。我一直在尝试使用 wiql,但我似乎没有让它工作。任何帮助或提示都值得赞赏。

我的代码:

  var Client = new RestClient("https://myvso.visualstudio.com/DefaultCollection/_apis/wit/wiql?api-version=1.0");
        Client.Authenticator = new HttpBasicAuthenticator(username, password);
        IRestRequest request = new RestRequest(Method.POST);
        request.AddHeader("Content-Type", "application/json");
        request.RequestFormat = DataFormat.Json;

        var query = JsonConvert.SerializeObject(new QueryModel() {query = "Select [System.Id] From WorkItems" });
        request.AddJsonBody(query);
        var response = Client.Execute(request);

我不断得到的错误是:

"{"count":1,"value":{"Message":"Error converting value \"{\"query\":\"Select [System.Id], From WorkItems\"}\" to type 'Microsoft.TeamFoundation.WorkItemTracking.Web.Models.Wiql'. Path '', line 1, position 52.\r\n"}}"

有人可以给我一个提示,说明我的查询有什么问题吗?

尝试以下操作:

删除:

var query = JsonConvert.SerializeObject(new QueryModel() {query = "Select [System.Id] From WorkItems" });

更新:

request.AddJsonBody(new {query = "Select [System.Id] From WorkItems" });

相关内容

  • 没有找到相关文章

最新更新