1

I'm writing a piece of code that will take in addresses input by the user, and return the latitude/longitude values for later use. For this, I'm using the Geocoding API. What I have is:

try
{
    IGeocoder geo = new GoogleGeocoder() { };
    Address[] addresses = geo.Geocode(address.Text).ToArray();
    foreach (Address adr in addresses)
    {
        // just testing it out
        MessageBox.Show(adr.Coordinates.ToString());
    }
}
catch (Exception ex)
{
    // error treating
}

address is a Textbox where the user types in the addresses. However, I get the 407 Error when I run it.

I've read many questions and tried their solutions (like this one, or this one), but none have worked.

Any ideas on what I'm missing?

  • Looks like an issue with the proxy penetration. There was no request from your machine (your firewall), or proxy didn't get it there (proxy's firewall), or your connection info (address, port, credentials) is wrong. If you really added App.config with the working credentials, proper local address, its port then what the firewalls are telling? – PIoneer_2 Oct 21 '21 at 12:58
  • where do you set up the url? did you try it with a rest client ? what did you get? – Leandro Bardelli Oct 22 '21 at 21:32

1 Answers1

1

Since it is throwing an error regarding proxy, you can try setting your proxy details to GoogleGeocoder class.

GoogleGeocoder geocoder = new GoogleGeocoder
{
    Proxy = new WebProxy
    {
        Address = new Uri("proxy url"),
        Credentials = new NetworkCredential("username", "password")
    }
};
cdev
  • 5,043
  • 2
  • 33
  • 32
  • Hi cdev, thanks for helping me out. However, it now throws another error: "no such host is known". – krobelusmeetsyndra Oct 27 '21 at 12:59
  • That is due to DNS failure, above call will try to connect google apis via proxy. Then proxy or your network is not able to resolve hosts. I suggest you to try google APIs using postman first. Figure out network problems first. Then adjust code accordingly. – cdev Oct 27 '21 at 14:06