Skip to main content
Question

Get Webhook Google Distance Matrix - INVALID REQUEST


I am running a GET Webhook with the URL https://maps.googleapis.com/maps/api/distancematrix/json when I hard code this link with the right params it works fine.  The information is retrieved. But when I put it into the Query String Params I receive an “INVALID_REQUEST”. I have even tried leaving the key=MY_API in the URL to see if that would help. I can not hard code the entire URL because the “destination” param comes from a form on our website. 

Any ideas what might be causing this? Is there something on the Google Cloud console side that could be causing this issue?

 

Did this topic help you find an answer to your question?
This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

12 replies

Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 30727 replies
  • November 13, 2024

Hi @laurenroth 

For us to have more info, post these screenshots:

  • how your Zap step is configured in EDIT mode with the field mappings
  • the encountered error

  • Author
  • Beginner
  • 6 replies
  • November 13, 2024

And just to confirm again, if I hard code the URL it works fine, so don’t think it is an API issue. 

 

Thanks


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 30727 replies
  • November 13, 2024

@laurenroth 

Couple things to check/try:

  • In the Query String Params section
    • for “destinations”, on the right side, remove “destinations=”
    • for “origins”, try removing all the + and instead use spaces
      • Zapier will properly encode the data when sent in the API request
    • for “destinations”, try removing all the + and instead use spaces
      • Zapier will properly encode the data when sent in the API request

 


  • Author
  • Beginner
  • 6 replies
  • November 13, 2024

Thanks for the feedback - Now I am getting this Error: “You must use an API key to authenticate each request to Google Maps Platform APIs. For additional information, please refer to http://g.co/dev/maps-no-account” 

I don’t really understand this because when I just put all the info into a URL is works fine. It makes me think there is some setting on the Google side where it doesn’t like talking to Zapier. Any ideas on what that might be? 

 

Thanks


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 30727 replies
  • November 13, 2024

@laurenroth 
What was the link to the Google API endpoint documentation you reference to configure the API request?

 

Try moving the key from the URL field to the Query String Parameters field.

 

If you need more help, post updated screenshots with how your Zap step is configured along with encountered errors.

 


  • Author
  • Beginner
  • 6 replies
  • November 13, 2024

 

Is this what you mean?


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 30727 replies
  • November 13, 2024

@laurenroth 

This is the link to the GMaps API endpoint documentation.

https://developers.google.com/maps/documentation/distance-matrix/distance-matrix

 

“origins” has a typo. (screenshot)

 


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 30727 replies
  • November 13, 2024

@laurenroth 

If that fix still results in an error for the API request, then try this:

Change it to this Zap action: Webhooks - Custom Request (GET)

For the URL field, include all of the query string parameters.

 


  • Author
  • Beginner
  • 6 replies
  • November 13, 2024

Alright the typo was not the issue. I used the Custom Request and got it to work (see images). But how do I get it to work when I want it to pull data coming from a form in the previous step?

Thanks!

 


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 30727 replies
  • November 13, 2024

@laurenroth 

You would need to map variables from a previous step to be in place of the desired query string parameter values.

Use the [+] button in a field to map variables.

If needed use this Zap action: Formatter > Text > URL Encode

 

Help link for how to configure Zap action steps: https://zapier.com/help/create/basics/set-up-your-zap-action

 

 


  • Author
  • Beginner
  • 6 replies
  • November 13, 2024

I can try that but why doesn’t the GET just work even when I hard code the information in? It is not related to the mapping if I am not trying to pull data but just hard code info in. Any ideas on why that doesn’t work correctly?


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 30727 replies
  • November 13, 2024

@laurenroth 

It could be related to the other field settings in the GET requests, but the screenshots did not show those fields to review.