Geocoding.net
Geocoding.net copied to clipboard
Exception thrown when using Geocoding google
Hi,
I receive this exception (sometimes) when sending geocoding requests
System.AggregateException occurred HResult=0x80131500 Message=One or more errors occurred. Source=mscorlib StackTrace: at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait() at Easymage.TEC.Entities.Application.QueryHandlers.AddressSearchQueryHandler.Handle(AddressSearchQuery query) in C:\Users\Ludovic\Source\Repos\Easymage.TEC\Easymage.TEC.Entities.Application\QueryHandlers\AddressSearchQueryHandler.cs:line 32
Inner Exception 1: GoogleGeocodingException: There was an error processing the geocoding request. See Status or InnerException for more information.
See Status or InnerException for more information.
What is the status or inner exception? That is where the error will be.
[0] {"There was an error processing the geocoding request. See Status or InnerException for more information."} System.Exception {Geocoding.Google.GoogleGeocodingException} Data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal} HResult -2146233088 int HelpLink null string InnerException null System.Exception Message "There was an error processing the geocoding request. See Status or InnerException for more information." string Source "Geocoding.Google" string StackTrace " at Geocoding.Google.GoogleGeocoder.<ProcessWebResponse>d__46.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Geocoding.Google.GoogleGeocoder.<ProcessRequest>d__39.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Geocoding.Google.GoogleGeocoder.<GeocodeAsync>d__34.MoveNext()" string Status Error Geocoding.Google.GoogleStatus
-
TargetSite {Void MoveNext()} System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
I get the same error. About every 10 requests but it varies.
Mine was a over query limit, throttling it ~10s per request and adding a retry with a longer delay removed this, mostly. Apparently you can still get them regardless using the anonymous api.
I encountered the same error. However, the InnerException was null which was helping not at all.
Getting an API Key solved the issue immediately. A snippet that might help:
var geoCoder = new Geocoding.Google.GoogleGeocoder();
geoCoder.ApiKey = "YourAPIKey";
var address = geoCoder.Geocode( ... )
@aatmmr I had the same error. thanks for the tips.
Geocoding.Google.GoogleGeocoder g = new Geocoding.Google.GoogleGeocoder(geocodingApiKey);
//setting the apiKey in the constructor seems not to be enough
g.ApiKey = geocodingApiKey;
I was getting the same issue and tried the suggestions above without success. I made the mistake of using the https string with the key. Using only the key worked.