5

我正在从事 CodedUI 测试自动化项目。VSTS我正在开发一个框架,我试图在其中访问测试用例RestAPI。我以前在一个 MVC 应用程序上工作过,在其中我做了同样的事情来从VSTS使用RestAPI.

现在的问题是我无法访问VSTS. 每次我尝试访问时VSTS,我都会遇到异常TF400813: Resource not available for anonymous access. Client authentication required
我正在使用相同的PAT token. 我拥有团队项目所需的所有访问权限。我可以从浏览器访问我项目中的所有工作项。我已经尝试了下面线程中提到的所有选项,但仍然无法正常工作。
启动 Visual Studio 2015.3 时出现客户端身份验证错误,
我们将不胜感激。
以下是我从中获取数据的代码VSTS

public static List<WorkItem> GetWorkItemsWithSpecificFields(IEnumerable<int> ids)
{
    var collectionUri = "https://<name>.visualstudio.com";
    var fields = new string[] {
        "System.Id",
        "System.Title",
        "System.WorkItemType",
        "Microsoft.VSTS.Scheduling.RemainingWork"
    };
    using (WorkItemTrackingHttpClient workItemTrackingHttpClient = new WorkItemTrackingHttpClient(new Uri(collectionUri), new VssBasicCredential("", System.Configuration.ConfigurationManager.AppSettings["PATToken"])))
    {
        // Exception is coming on below line
        List<WorkItem> results = workItemTrackingHttpClient.GetWorkItemsAsync(ids, fields).Result;
        return results;
    }
}
4

0 回答 0