0

我需要通过 REST 从 Azure Devops 2019 获取用户配置文件图像,但它以“NonAuthoritativeInformation”状态响应。我想知道我是否遗漏了什么或在我的请求标头中添加了任何错误。代码如下:

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

1 回答 1

0

Profiles API 仅支持Azure DevOps Services。它不支持Azure DevOps Server (TFS 2019)。如果您选择 Azure DevOps Server 2019 的 api 版本,您将看到以下警告消息:

在此处输入图像描述

于 2020-04-15T03:29:45.270 回答