Quantcast
Channel: Team Foundation Server - General forum
Viewing all articles
Browse latest Browse all 6687

How to access team project list or Git project list using TFS REST API

$
0
0

Hi ,

I am trying the following to get list of projects from "on prem" TFS 

  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());
            }
        }

I am using a user name and password which has admin permissions on TFS i am trying to connect.But i get unauthorized access error when i try the above.


Viewing all articles
Browse latest Browse all 6687

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>