I am using the geocoding API passing postal codes (GB mainly) to validate if the postal code is valid or not (using the address_components and types where if it returns "postal_code" I take that it is valid) but I have found 2 issues.
Also is this the best method with Google Maps to validate a postal code?
- I am posting https://maps.googleapis.com/maps/api/geocode/json?address=GU27YP&components=country:GB&key= where the postal code of GU2 7YP is sent and in the response it is giving me a different postal code (GU2 7UP). Why is this doing this, is it telling me that the postal code no longer exists (in 2016 it was removed) and now this other 1 has replaced it?
"address_components": [ { "long_name": "GU2 7UP", "short_name": "GU2 7UP", "types": [ "postal_code" ] },
- I am validating postal code OL1 1NY (GB) and it returns a positive result but the postal code is no longer recognised by Royal Mail and was removed in Dec 2022. Is there a way to get Google to update it?
"address_components": [ { "long_name": "OL1 1NY", "short_name": "OL1 1NY", "types": [ "postal_code" ] },
For both issues I was expecting that would give me a response without a postal code match and would state the below as it does for another invalid postal code of ME4 4QQ
"address_components": [
{
"long_name": "United Kingdom",
"short_name": "GB",
"types": [
"country",
"political"
]
}
Thanks