我正在开发CodedUI测试自动化项目 . 我正在开发一个框架,我试图通过 RestAPI
访问 VSTS
中的测试用例 . 我之前曾参与过一个MVC应用程序,我使用 RestAPI
从 VSTS
中提取数据 .
现在问题是我无法访问 VSTS
. 每次我试图访问 VSTS
时,我都得到了异常 TF400813: Resource not available for anonymous access. Client authentication required
.
我使用相同的 PAT token
. 我拥有团队项目所需的所有权限 . 我可以从浏览器访问项目中的所有工作项 . 我已经尝试了下面的线程中提到的所有选项,但仍然无法正常工作 .
Client authentication error when starting 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;
}
}