Unexpected behavior when passing lat/lng AND partial address through bulk API

The documentation for the API notes that “each query must have non-blank values for at least one of the following combinations”:

  • query.latitude + query.longitude
  • query.street_address + query.city + query.region + query.postal_code + query.iso_country_code

But when submitting a bulk query the API returns a 400 status code error if city and postal code are missing, even if there is a valid lat/lng.

Given that placekey is checking the lat/lng first, should it fail when a partial address is used?

Thanks in advance for any thoughts/guidance!

Example that returns 400 status_code (same result with NA or NULL in city and postal_code:

response <- POST('https://api.placekey.io/v1/placekeys',
                 body = list(queries = list(
                   list(
                     latitude = 35.97922,
                     longitude = -78.78797,
                     street_address = '302 PATTERSON RD',
                     city = '',
                     region = 'NC',
                     postal_code = '',
                     iso_country_code = 'US'
                   ),
                   list(
                     latitude = 35.95072,
                     longitude = -78.95743,
                     street_address = '3608 WESTOVER RD',
                     city = '',
                     region = 'NC',
                     postal_code = '',
                     iso_country_code = 'US'
                   )
                 )
                 ),
                 add_headers(apikey = Sys.getenv("PLACEKEY_SECRET")),
                 encode = 'json')

Working version without partial address:

response <- POST('https://api.placekey.io/v1/placekeys',
                 body = list(queries = list(
                   list(
                     latitude = 35.97922,
                     longitude = -78.78797
                   ),
                   list(
                     latitude = 35.95072,
                     longitude = -78.95743
                   )
                 )
                 ),
                 add_headers(apikey = Sys.getenv("PLACEKEY_SECRET")),
                 encode = 'json')

Hi @mtdukes , I’m a bit surprised the Placekey API isn’t handling these types of requests.

I’m wondering if including the blank strings is causing an issue. Could you try the top request again and remove the city and postal_code lines completely (while still including the other partial address info)?

If that works, we would appear to have a workaround. If it does not work, we’ll get in touch with someone to dig in further.