0

I need to fetch user profile image from Azure Devops 2019 through REST but it is responding with "NonAuthoritativeInformation" status. I want to know if I am missing something or adding anything wrong in my request header. Code is given below:

string url = "https://app.vssps.visualstudio.com/_apis/profile/profiles/{640a73ee-ff0c-45b7-85c2-cd1cd6e3a7cb}/avatar";
            WebRequest webRequest = WebRequest.Create(url);
            webRequest.ContentType = "application/octet-stream";
            webRequest.Method = WebRequestMethods.Http.Get;
            webRequest.Credentials = CredentialCache.DefaultNetworkCredentials;
            webRequest.PreAuthenticate = true;
            webRequest.Headers.Add("Authorization", "Bearer {" + this.mOAuthAccessToken+"}");

            using (HttpWebResponse response = webRequest.GetResponse() as HttpWebResponse)
            {
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    using (Stream responseStream = response.GetResponseStream())
                    {
                        var filestreamreader = new StreamReader(responseStream);
                        string result = filestreamreader.ReadToEnd();
                    }
                }
            }
Daniel Mann
  • 57,011
  • 13
  • 100
  • 120

1 Answers1

0

Profiles API only supports Azure DevOps Services. It doesn't support Azure DevOps Server (TFS 2019). If you choose the api version for Azure DevOps Server 2019, you would see the warning message bellow:

enter image description here

Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39
  • I cant see the image you attached. – Muhammad Arsalan Younus Apr 15 '20 at 15:45
  • Go to link https://learn.microsoft.com/en-us/rest/api/azure/devops/profile/profiles/get?view=azure-devops-rest-5.1, and then select Azure DevOps Server 2019 version, you 'll see the warning message "The requested page is not available for Azure DevOps Server 2019. You have been redirected to the newest product version this page is available for." – Cece Dong - MSFT Apr 16 '20 at 01:40