I am working on the CodedUI Test Automation project. i am developing a framework in which i am trying to access Test Cases in VSTS
through RestAPI
. I have worked on an MVC application previously in which i did the same thing to pull data from VSTS
using RestAPI
.
Now the problem is i am not able to access the VSTS
. Everytime i am trying to access the VSTS
, i got the exception TF400813: Resource not available for anonymous access. Client authentication required
.
I am using the same PAT token
. I have all the required access on my team project. I am able to access all work items in my project from browser. I have tried all the option mentioned in below thread but still its not working.
Client authentication error when starting Visual Studio 2015.3
Any leads will be appreciated.
Below is my code to get data from 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;
}
}