2017-02-22 1 views
0

webClient.Download ("URI") 함수에 문제가 있습니다. URL을 https (내가 제안한 것)로 변경해야했기 때문에 작동했습니다. 브라우저에 요청 URI를 붙여 넣으면 유효한 Json String을 얻습니다. DownloadString ("URI") 메서드로 호출하면 결과가 0으로됩니다. 내 코드에 키가 포함되어있어이 게시물에 대해 삭제되었습니다. 당신이하지 않은 key 매개 변수를 제공해야C# Webclient Json 파일의 String Zero 결과 다운로드

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