You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When Google responds with an error, for example with the Geocoding API, they respond with JSON describing the problem, but also set the HTTP status code to 400. gmaps-api-net uses HttpClient, which throws for non-200 codes, and doesn't catch them.
Example Google response with 400 code:
{
"error_message" : "Invalid request. Missing the 'address', 'components', 'latlng' or 'place_id' parameter.",
"results" : [],
"status" : "INVALID_REQUEST"
}
Stack trace when this happens:
System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Google.Maps.Internal.MapsHttp.d__4`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Google.Maps.Internal.MapsHttp.Get[T](Uri uri)
What should be happening instead:
gmaps-api-net should be handling the non-200 code and instead returning the appropriately deserialized GeocodeResponse type, which will have the ServiceResponseStatus Status field set to InvalidRequest.
The text was updated successfully, but these errors were encountered:
When Google responds with an error, for example with the Geocoding API, they respond with JSON describing the problem, but also set the HTTP status code to 400. gmaps-api-net uses HttpClient, which throws for non-200 codes, and doesn't catch them.
Example Google response with 400 code:
{
"error_message" : "Invalid request. Missing the 'address', 'components', 'latlng' or 'place_id' parameter.",
"results" : [],
"status" : "INVALID_REQUEST"
}
Stack trace when this happens:
System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Google.Maps.Internal.MapsHttp.d__4`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Google.Maps.Internal.MapsHttp.Get[T](Uri uri)
What should be happening instead:
gmaps-api-net should be handling the non-200 code and instead returning the appropriately deserialized GeocodeResponse type, which will have the ServiceResponseStatus Status field set to InvalidRequest.
The text was updated successfully, but these errors were encountered: