2017-07-26 107 views
-4

任何人都可以帮我翻译这个curl命令到C#https GET请求吗?curl命令到C#mbed API

curl -v -H 'Authorization: Bearer <your_access_key>' https://api.connector.mbed.com/endpoints/ 
+4

你尝试过什么到目前为止? –

+0

['WebClient'](https://msdn.microsoft.com/library/system.net.webclient)是你的朋友。 –

+0

或带额外头文件的HttpClient。 https://stackoverflow.com/questions/35907642/custom-header-to-httpclient-request –

回答

0

试试这个:

WebClient client = new WebClient(); 
client.Headers.Add("Authorization", "Bearer <your_access_key>"); 
string response = client.DownloadString("https://api.connector.mbed.com/endpoints/"); 
+0

非常感谢您的回答,它与引号内的URI一起工作 –

+0

如果答案解决了您的问题,请打勾答案为“已接受”(带有小复选框)。谢谢! –

+0

对不起,我是新来的,这实际上是我的第一个问题 –