![](/img/trans.png)
[英]How do I do a SAML login request, without using a third party control?
[英]How do i do a request to a third party api? using httpclient
目前,我需要集成CoinGecko API,這是一個向公眾開放的免費API。 ( https://www.coingecko.com/api/docs/v3 )
HTTP客戶端發送請求但它永遠不會返回響應
string BaseUrl = "https://api.coingecko.com/api/v3";
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(BaseUrl);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = await client.GetAsync("/coins/list");
if (response.IsSuccessStatusCode)
{
var data = await response.Content.ReadAsStringAsync();
var table = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.Coins>>(data);
}
預期的結果是它應該返回硬幣列表,但它永遠不會。
將BaseUrl更改為:
string BaseUrl = "https://api.coingecko.com";
和GetAsync調用
HttpResponseMessage response = await client.GetAsync("/api/v3/coins/list");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.