【问题标题】:C# Webclient Download String Zero Result in Json FileC# Webclient 在 Json 文件中下载字符串零结果
【发布时间】: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");

【问题讨论】:

    标签: c# json webclient


    【解决方案1】:

    documentation 声明您必须提供您没有提供的 key 参数。

    【讨论】:

    • 我在代码中添加了一个键,只是这里没有,抱歉
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-12
    • 1970-01-01
    • 2020-09-18
    相关资源
    最近更新 更多