简体   繁体   中英

Error 407 (Proxy Authentication Request) on Web Request via Geocoding API

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM