I have the following code that when I type the postal code it returns with the data of my country, but I would like to do a search using the postal code of other countries. How can I adapt my structure to my code?
public ActionResult Pesquisar(string zipCode)
{
string key = ConfigurationManager.AppSettings.Get("keyAPIGoogleCloudServices");
ReplyZipCodeGoogle ReplyZipCodeGoogle = null;
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://maps.google.com/maps/api/geocode/");
//HTTP GET
var parameters = "&sensor=false&languague=pt-BR®ion=br";
var key = "&key=" + key;
var research = "json?address=" + zipCode;
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3170;
//var responseTask = client.GetAsync("json?address=29102-100&sensor=false&languague=pt-BR®ion=br&key=AIzaSyDPFP6WqSoSiECqAJqE1P3kVkueJAujVtQ");
var responseTask = client.GetAsync(pesquisa + parameters + key);
responseTask.Wait();
var result = responseTask.Result;
if (result.IsSuccessStatusCode)
{
var readTask = result.Content.ReadAsAsync<ReplyZipCodeGoogle>();
readTask.Wait();
ReplyZipCodeGoogle = readTask.Result;
}
else //web api sent error response
{
}
}
if(RespostaCepGoogle.Status == "ZERO_RESULTS")
throw new CoreException("Zip code does not exist. Please enter a valid zip code.");
}
How can I adapt a way to get the zip code from Paraguay, for example?