【发布时间】:2017-02-22 12:56:37
【问题描述】:
我的 webClient.Download("URI") 函数有问题。它起作用了,因为我不得不将 URL 更改为 https(我的建议)。如果我将我的请求 URI 粘贴到浏览器中,我会得到一个有效的 Json 字符串,如果我使用 DownloadString("URI") 方法调用它,我会得到零结果 我的代码包含一个密钥,只是在此处为这篇文章删除了它 这是我的代码:
var json = "";
Console.WriteLine("Connect zur Google API Geo Coding API");
locations = locations.Replace(" ", "+");
//request the google geocoding api. limit of 2500 requests/day
String requestUri = "https://maps.googleapis.com/maps/api/geocode/json?address=Serba,++Am+Schwemmberg,+Germany";
Console.WriteLine("Hat geklappt");
//get the json string
Console.WriteLine("starte den download des json");
var webClient = new WebClient();
//here it Returns "Zero result"
json = webClient.DownloadString(requestUri);
Console.WriteLine("Download des json beendet");
【问题讨论】: