简体   繁体   中英

connection Azure DevOps using REST API

I am trying to connect Azure DevOps in .net core application with following code.

var url = new Uri("https://abcdxyz.visualstudio.com");

var PAT = "XXXXXgdeuxfroaqho4lhtqjdvbagrotypfgfhtuq6w23ie5z3xoq";

VssConnection connection = new VssConnection(url, new VssBasicCredential(string.Empty, PAT));
WorkItemTrackingHttpClient witClient = connection.GetClient<WorkItemTrackingHttpClient>();

it builds successfully. However, it throws error as

System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Net.Http.WebRequest, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.'

I tried to update Nuget package. But still this error occurs.

Could you please let me know how to resolve this? thanks

I recall having a similar issue, and this is the way we get the WIT client in our .net core app that uses these libraries:

 vss = new VssBasicCredential(string.Empty, PAT);
 VssConnection connection = new VssConnection(tfsURI, vss);
 witClient = connection.GetClient<WorkItemTrackingHttpClient>();

 workItemClient = new WorkItemClient(witClient);

We are using the preview versions of the Microsoft.TeamFoundationServer.Client and Microsoft.VisualStudio.Services.Client libraries as well.

There is no .net core support ATM from my understanding. A coworker of mine commented on this open issue with some more context of how we made this work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM