Skip to main content

We’re collecting some basic information from users through a wireless portal when they connect to our guest network. Name, E-mail, and Zip Code. This information is passed onto Zapier utilizing Webhooks. I have some Zaps setup and they’re working great. The short of it is the information is collected, slightly modified, then passed on to other external sources as contacts and for logging. Everything works great unless someone inputs a bogus zip code. I’m using zipcodeapi.com to retrieve City and State from the Zip Code that the user enters. If the API fails to lookup the Zip Code because it’s invalid it kills the whole Zap with a error and the contact is never added. There has to be someway to bypass this step on error so I still get the Name and E-mail into MailChimp.

 

Thanks

8.7.3

@tim829, Thats a tricky one. You might want to consider changing your trigger from a webhook to a new row in airtable. 

 

You could try this:

Create a path that is expecting the ‘bogus zip code’. In order to be able to create that path, you might need to change your 🎳Trigger from a Webhook -> to a “New Row” in Airtable. In doing this, you’re trigger will be flexible enough to accommodate the varying data structure. Zapier Webhooks are rather specific with the information that it expects which is why you’re experiencing this issue with the zap turning off.

 

Hope that helps! Happy Zapping!


  @tim829 You could also try passing the data onto MailChimp twice. The first time send just the Name and Email, then do your API lookup and pass the ZIP code on a second MailChimp step. This way if the API lookup fails you will have already passed the Name and Email data. 


  @tim829 You could also try passing the data onto MailChimp twice. The first time send just the Name and Email, then do your API lookup and pass the ZIP code on a second MailChimp step. This way if the API lookup fails you will have already passed the Name and Email data. 

 

I’m going to give this a shot and see how it works.

8.7.3

Hi @tim829, you can also try making the API Call using a Code by Zapier Javascript action instead of the Webhooks by Zapier. That will allow you to evaluate the response and return the city and state if they are returned by the API, or empty values for both if the API call fails.

Here is what the setup would look like if I manually entered zip code 0202020 which should throw an error. Of course when you do yours you should map the zip to your trigger’s zip code field.

 

And here you can see it returns blank values for city and state:

 

On the other hand, for a valid Zip code such as 33315 it will return the full response:

 

Here is the code that makes that happen. Please note the parameter we are sending is called “zip” as noted in the first screenshot above and requires that you map it to your trigger’s zip code field.

 

var url = "http://www.zipcodeapi.com/rest/N3LzfSo8XW9ZQjaswBmsWuILLrP7VtYpTCqguEcTgLb4cYYm32ZtXS1wC7Q2e9Lf/info.json/" + inputData.zip + "/degrees";

//The HTTP request
let response = await fetch(url, {
method: 'GET'
});

//Error Handling. If it fails we return the response. If not we return the JSON of the response.
if (response.ok) {
let json = await response.json();
return json;
} else {
return { city: "", state: ""};
}

Try it out and see if it works. Cheers!


@tim829 
Just checking in to see if you still need help with this?