2017-02-22 1 views
0

webClient.Download( "URI")関数に問題があります。私はURLをhttpsに変更しなければならなかったので、うまくいきました。リクエストURIをブラウザに貼り付けると、有効なJson Stringが取得されます。これをDownloadString( "URI")メソッドで呼び出すと、結果としてゼロ結果が得られます My Codeにはキーが含まれています。あなたはなかったkeyパラメータを提供する必要がC#WebclientダウンロードJsonファイルの文字列ゼロの結果

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"); 

答えて

1

documentation状態:ここ ここに私のコードです。

+0

私のコードにキーを追加しましたが、ここにはありません。ごめんなさい – Christian

関連する問題