Skip to main content
adicionou 450 caracteres ao conteúdo
Fonte Link
João Martins
  • 5,7mil
  • 5
  • 16
  • 33

Experimente desta forma:

var client = new RestClient("https://maps.googleapis.com/");
var request = new RestRequest(Method.GET);

request.Resource = "maps/api/geocode/json?address={cep}&key={key}";
request.AddParameter("cep", cep, ParameterType.UrlSegment);
request.AddParameter("key", key, ParameterType.UrlSegment);

var response = client.Execute(request);

Outra forma, desta vez com WebRequest:

string url = $"https://maps.googleapis.com/maps/api/geocode/json?address={cep}&key={key}";

WebRequest request = WebRequest.Create(url);
WebResponse response = request.GetResponse();

Stream data = response.GetResponseStream();
StreamReader reader = new StreamReader(data);

string responseFromServer = reader.ReadToEnd();

response.Close();

Experimente desta forma:

var client = new RestClient("https://maps.googleapis.com/");
var request = new RestRequest(Method.GET);

request.Resource = "maps/api/geocode/json?address={cep}&key={key}";
request.AddParameter("cep", cep, ParameterType.UrlSegment);
request.AddParameter("key", key, ParameterType.UrlSegment);

var response = client.Execute(request);

Experimente desta forma:

var client = new RestClient("https://maps.googleapis.com/");
var request = new RestRequest(Method.GET);

request.Resource = "maps/api/geocode/json?address={cep}&key={key}";
request.AddParameter("cep", cep, ParameterType.UrlSegment);
request.AddParameter("key", key, ParameterType.UrlSegment);

var response = client.Execute(request);

Outra forma, desta vez com WebRequest:

string url = $"https://maps.googleapis.com/maps/api/geocode/json?address={cep}&key={key}";

WebRequest request = WebRequest.Create(url);
WebResponse response = request.GetResponse();

Stream data = response.GetResponseStream();
StreamReader reader = new StreamReader(data);

string responseFromServer = reader.ReadToEnd();

response.Close();
Fonte Link
João Martins
  • 5,7mil
  • 5
  • 16
  • 33

Experimente desta forma:

var client = new RestClient("https://maps.googleapis.com/");
var request = new RestRequest(Method.GET);

request.Resource = "maps/api/geocode/json?address={cep}&key={key}";
request.AddParameter("cep", cep, ParameterType.UrlSegment);
request.AddParameter("key", key, ParameterType.UrlSegment);

var response = client.Execute(request);