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