我想我使用它有一个用户名和密码,以下为“关于炳”获得从项目列表TFS如何使用TFS REST API
private static async void Method()
{
try
{
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(
new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
Convert.ToBase64String(
System.Text.ASCIIEncoding.ASCII.GetBytes(
string.Format("{0}:{1}", "Username", "Password"))));
using (HttpResponseMessage response = client.GetAsync(
"http://test-test-app1:8080/tfs/boc_projects/_apis/projects?api-version=2").Result)
{
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
访问团队项目列表或Git项目名单管理员权限在TFS我想连接。但是当我尝试上述时,我得到未经授权的访问错误。
我推荐使用目录服务,而不是REST API,仅仅是因为它不需要管理员权限。如果你有兴趣,我有代码。 –
告诉我有关Catalog Service的更多信息,我不知道它 –