Skip to main content

I’m trying to build a Zap to integrate Airtable with Google Maps API Reverse Geocoding service. Everything works as expected until I try to extract the values passed back from the API.

In summary, I pass a Lat / Long to the Google Maps API and it returns potential address matches. I want to extract just the first (most likely) address match and add it to the Airtable record.

Below is an example of the full JSON response copied from the ‘Test action’ tab of the Webhook Step. You can see there are several addresses returned from the query.

plus_code
compound_code
VHXV+4R San Francisco, Nayarit, Nayarit, Mexico
global_code
75GPVHXV+4R
results
1
address_components
1
long_name
66
short_name
66
types
1
street_number
2
long_name
Nueva Galicia
short_name
Nueva Galicia
types
1
route
3
long_name
Nayarit
short_name
Nay.
types
1
administrative_area_level_1
2
political
4
long_name
Mexico
short_name
MX
types
1
country
2
political
formatted_address
Nueva Galicia 66, Nayarit, Mexico
geometry
location
lat
20.897784
lng
-105.4057536
location_type
ROOFTOP
viewport
northeast
lat
20.8991329802915
lng
-105.4044046197085
southwest
lat
20.89643501970849
lng
-105.4071025802915
place_id
ChIJNRq8Dog9IYQRJ6sl-U5qBGY
plus_code
compound_code
VHXV+4M San Francisco, Nayarit, Nayarit, Mexico
global_code
75GPVHXV+4M
types
1
street_address
2
address_components
1
long_name
48
short_name
48
types
1
street_number
2
long_name
Nueva Galicia
short_name
Nueva Galicia
types
1
route
3
long_name
San Francisco
short_name
San Francisco
types
1
locality
2
political
4
long_name
Nayarit
short_name
Nay.
types
1
administrative_area_level_1
2
political
5
long_name
Mexico
short_name
MX
types
1
country
2
political
formatted_address
Nueva Galicia 48, San Francisco, Nay., Mexico
geometry
location
lat
20.8972048
lng
-105.4063307
location_type
ROOFTOP
viewport
northeast
lat
20.8985537802915
lng
-105.4049817197085
southwest
lat
20.8958558197085
lng
-105.4076796802915
place_id
ChIJG7ezSPw9IYQRMTR8FQYwUWA
plus_code
compound_code
VHWV+VF San Francisco, Nayarit, Nayarit, Mexico
global_code
75GPVHWV+VF
types
1
establishment
2
lodging
3
point_of_interest
3
address_components
1
long_name
48
short_name
48
types
1
street_number
2
long_name
Nueva Galicia
short_name
Nueva Galicia
types
1
route
3
long_name
San Francisco
short_name
San Francisco
types
1
locality
2
political
4
long_name
Nayarit
short_name
Nay.
types
1
administrative_area_level_1
2
political
5
long_name
Mexico
short_name
MX
types
1
country
2
political
formatted_address
Nueva Galicia 48, San Francisco, Nay., Mexico
geometry
bounds
northeast
lat
20.8972825
lng
-105.4063166
southwest
lat
20.8971445
lng
-105.4064652
location
lat
20.8971941
lng
-105.4063732
location_type
ROOFTOP
viewport
northeast
lat
20.8985624802915
lng
-105.4050419197085
southwest
lat
20.8958645197085
lng
-105.4077398802915
place_id
ChIJtYmuG4g9IYQRvPMEFCD-ebE
types
1
premise
4
address_components
1
long_name
32-66
short_name
32-66
types
1
street_number
2
long_name
Nueva Galicia
short_name
Nueva Galicia
types
1
route
3
long_name
Nayarit
short_name
Nay.
types
1
administrative_area_level_1
2
political
4
long_name
Mexico
short_name
MX
types
1
country
2
political
formatted_address
Nueva Galicia 32-66, Nayarit, Mexico
geometry
bounds
northeast
lat
20.8987898
lng
-105.4056545
southwest
lat
20.8967306
lng
-105.4066277
location
lat
20.8976723
lng
-105.4058131
location_type
GEOMETRIC_CENTER
viewport
northeast
lat
20.8991091802915
lng
-105.4047921197085
southwest
lat
20.89641121970849
lng
-105.4074900802915
place_id
ChIJ41ndBYg9IYQR6MkWMtLGrRQ
types
1
route
5
address_components
1
long_name
25
short_name
25
types
1
street_number
2
long_name
Calle Birmania
short_name
Calle Birmania
types
1
route
3
long_name
San Francisco
short_name
San Francisco
types
1
locality
2
political
4
long_name
Nayarit
short_name
Nay.
types
1
administrative_area_level_1
2
political
5
long_name
Mexico
short_name
MX
types
1
country
2
political
formatted_address
Calle Birmania 25, San Francisco, Nay., Mexico
geometry
location
lat
20.8986121
lng
-105.4078081
location_type
RANGE_INTERPOLATED
viewport
northeast
lat
20.8999610802915
lng
-105.4064591197085
southwest
lat
20.89726311970849
lng
-105.4091570802915
place_id
Ei5DYWxsZSBCaXJtYW5pYSAyNSwgU2FuIEZyYW5jaXNjbywgTmF5LiwgTWV4aWNvIhoSGAoUChIJN8dsEigWIYQRTW6xb6UAgR4QGQ
types
1
street_address
6
address_components
1
long_name
Bahía de Banderas
short_name
Bahía de Banderas
types
1
administrative_area_level_2
2
political
2
long_name
Nayarit
short_name
Nay.
types
1
administrative_area_level_1
2
political
3
long_name
Mexico
short_name
MX
types
1
country
2
political
formatted_address
Bahía de Banderas, Nayarit, Mexico
geometry
bounds
northeast
lat
20.9864276
lng
-104.9574149
southwest
lat
20.6719086
lng
-105.5393528
location
lat
20.8074834
lng
-105.2480864
location_type
APPROXIMATE
viewport
northeast
lat
20.9864276
lng
-104.9574149
southwest
lat
20.6719086
lng
-105.5393528
place_id
ChIJDYlqBWo4IYQRN-YEFKOuFF0
types
1
administrative_area_level_2
2
political
7
address_components
1
long_name
Nayarit
short_name
Nay.
types
1
administrative_area_level_1
2
political
2
long_name
Mexico
short_name
MX
types
1
country
2
political
formatted_address
Nayarit, Mexico
geometry
bounds
northeast
lat
23.0845034
lng
-103.7208954
southwest
lat
20.6032209
lng
-106.6877266
location
lat
21.7513844
lng
-104.8454619
location_type
APPROXIMATE
viewport
northeast
lat
23.0845034
lng
-103.7208954
southwest
lat
20.6032209
lng
-106.6877266
place_id
ChIJR9s-5pyoIIQROdKUhqL1yMI
types
1
administrative_area_level_1
2
political
8
address_components
1
long_name
Mexico
short_name
MX
types
1
country
2
political
formatted_address
Mexico
geometry
bounds
northeast
lat
32.7186534
lng
-86.5887
southwest
lat
14.3895
lng
-118.6523001
location
lat
23.634501
lng
-102.552784
location_type
APPROXIMATE
viewport
northeast
lat
32.7186534
lng
-86.5887
southwest
lat
14.3895
lng
-118.6523001
place_id
ChIJU1NoiDs6BIQREZgJa760ZO0
types
1
country
2
political
9
address_components
1
long_name
VHXV+4R
short_name
VHXV+4R
types
1
plus_code
2
long_name
San Francisco, Nayarit
short_name
San Francisco, Nayarit
types
1
locality
2
political
3
long_name
Nayarit
short_name
Nay.
types
1
administrative_area_level_1
2
political
4
long_name
Mexico
short_name
MX
types
1
country
2
political
formatted_address
VHXV+4R San Francisco, Nayarit, Nayarit, Mexico
geometry
bounds
northeast
lat
20.897875
lng
-105.405375
southwest
lat
20.89775
lng
-105.4055
location
lat
20.89782
lng
-105.405471
location_type
ROOFTOP
viewport
northeast
lat
20.8991614802915
lng
-105.4040885197085
southwest
lat
20.8964635197085
lng
-105.4067864802915
place_id
GhIJ2bERiNflNEARfR6jPPNZWsA
plus_code
compound_code
VHXV+4R San Francisco, Nayarit, Nayarit, Mexico
global_code
75GPVHXV+4R
types
1
plus_code
status
OK

When I copy/paste it seems to flatten the structure, though it actually looks like this:

If I try to access these values in the next Step, I see this:

 

Zapier has identified the keys in the response but grouped them together and I cannot work out how to access only the first address passed back in the response.

I found this community post which appeared helpful but the ‘Line-items to Text’ function did not work as expected.

Another post suggest this could be easily extracted using some Javascript in a Code Step but I can’t work out how to pass the raw JSON response to run the code on. I only have access to the input data from the above screen shot.

Would really appreciate a little guidance from the Community to get over the finish line with this project.

Felix

Hi @felixcarver,

 

The “Line Items to Text” option should get the job done, however, since it’s not working for you, you can use a zapier app called “looping by zapier”.

Use “Looping by Zapier>Loop from line items” and set the maximum iteration to 1 so that the first item only goes through. 

 

https://zapier.com/apps/looping/integrations