0
我正在嘗試從API中獲取REST數據,但我需要使用某些服務器端解決方案來處理對API的調用。我曾嘗試使用以下代碼如何使用ASP.NET MVC從服務器端調用API?
try
{
HttpClient client = new HttpClient();
client.Timeout = TimeSpan.FromSeconds(60);
var request = new HttpRequestMessage()
{
RequestUri = new Uri(string.Format("https://jsonodds.com/{0}{1}{2}", "api/odds/", "?source=", "3")),
Method = HttpMethod.Get,
};
request.Headers.Add("JsonOdds-API-Key", "your key");
HttpResponseMessage response = client.SendAsync(request).Result;
if (response.IsSuccessStatusCode)
{
String.Format("Success");
}
}
catch (Exception ex)
{ //log error }
我收到407()錯誤。任何想法或提示如何做到這一點?
'407' =「HTTP錯誤407需要代理驗證」<=似乎您的憑證沒有按順序。 – Igor