Visual Studio online Rest API时增强的安全性错误 [英] Enhanced Security Error while Visual Studio online Rest API

查看:66
本文介绍了Visual Studio online Rest API时增强的安全性错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试使用Visual Studio在线公开的Rest API来获取工作项信息。我似乎能够连接,但是当我查看对我的查询的响应时,它是一个带有增强安全错误消息的html页面。我认为
这是由于IE中的增强安全性选项,但是我从我的客户机上调用它,我只能看到如何在服务器上关闭它的选项。



这是我正在拨打的电话



公共静态异步任务RunAsync()

        {

            var token =" xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ;;



$
            //编码您的个人访问令牌                  



            string credentials = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format(" {0}",token)));
$




            //使用httpclient

           使用(var client = new HttpClient())

            {

                client.BaseAddress = new Uri(" https://chesstelecom.visualstudio.com");   //我们帐户的网址

                client.DefaultRequestHeaders.Accept.Clear();

                client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue(" application / json"));

                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(" Basic",credentials);



                //连接到REST端点           

                HttpResponseMessage响应= client.GetAsync(" Core / _apis / wit / queries?$ depth = 1& $ expand = all& api-version = 2.2")。结果;



                //检查我们是否有成功的回复

                if(response.IsSuccessStatusCode)

                {

$
                    var value = response.Content.ReadAsStringAsync()。结果;

                }¥b $ b            }¥b $ b        }


当我使用浏览器时,查询工作正常,但不是通过视觉工作室



任何帮助这将是值得赞赏的,



谢谢你


克里斯

解决方案

您好,


感谢您在此处发帖。


这是
MSDN主题
已讨论了类似的问题,可以帮助您解决问题。


另外,请查看以下链接并让我们知道反馈意见。


https://4sysops.com/archives/four-ways-to-disable-internet-explorer-enhanced-security-configuration-ie-esc/


<希望它有所帮助!


问候,


Di免责声明:

此回复包含对第三方万维网站点的引用。 Microsoft提供此信息是为了方便您。 Microsoft不控制这些网站,也未测试在这些网站上找到的任何软件或信息;因此,
Microsoft不能就其中发现的任何软件或信息的质量,安全性或适用性做出任何陈述。使用互联网上的任何软件都存在固有的危险,微软提醒您在从互联网上检索任何软件之前确保您完全了解风险。 

_______________________________________________________________________________________________________


如果帖子回答了你的问题,请点击该帖子上的标记为答案并投票为有用。


I'm currently trying to use the Rest APIs exposed by Visual Studio online to obtain work item information. I seem to be able to connect however when I look at the response to my query its a html page with a Enhanced Security Error message. I believe that this is due to the Enhanced Security option in IE but I'm calling this from my client machine and I can only see options on how to turn this off on a server.

this is the call i'm making

public static async Task RunAsync()
        {
            var token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";


            //encode your personal access token                   

            string credentials = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}", token)));


            //use the httpclient
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("https://chesstelecom.visualstudio.com");  //url of our account
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", credentials);

                //connect to the REST endpoint            
                HttpResponseMessage response = client.GetAsync("Core/_apis/wit/queries?$depth=1&$expand=all&api-version=2.2").Result;

                //check to see if we have a succesfull respond
                if (response.IsSuccessStatusCode)
                {

                    var value = response.Content.ReadAsStringAsync().Result;
                }
            }
        }

The query works fine when I use a browser however not through visual studio

any help with this would be appreciated,

thanks

Chris

解决方案

Hi,

Thanks for posting here.

Here is the MSDN thread which has discussed the similar issue which may help u to resolve your issue.

Also, go through the below link and let us know the feedback.

https://4sysops.com/archives/four-ways-to-disable-internet-explorer-enhanced-security-configuration-ie-esc/

Hope it Helps!

Regards,

Disclaimer:
This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet. 

_______________________________________________________________________________________________________

If a post answers your question, please click Mark as Answer on that post and Vote as Helpful.


这篇关于Visual Studio online Rest API时增强的安全性错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆