Best answer

Webhook zap even though "POST" fail.

  • 19 August 2022
  • 6 replies
  • 122 views

I’m running a zap that gets data from Gravity Forms make a payload from that data and post it to an API . My problem is that for some reason one variable is a comments field. This means that post command fails because my code suddenly have line breaks. Se last line below:

			"public_comments": "<br><b>Anmeldt af:</b> XXX<br><b>Anmeldelsestype:</b> Forsikring anmeldelse<br> <b>Produkt:</b> XXX  <br><b>Type:</b> XXX<br> <b>Afhentning:</b> Hurtigst muligt (Normalt næste hverdag) <br> <b>Afhentes fra:</b><br> XXX<br>XXX 22 B<br>XXXX XXX<br><b>Retur til:</b> <br> <br><br> <br><br><b>Forløb:</b> Dette er en test 


mon det virker nu? påøæ+?=)(/&%"

Even though the “POST” fails the zap se it as a success.. 

Problem 1: I cannot find a way to get rid of that line break with zapier.

Problem 2: How do I get Zapier to fail the zap and notify me if there is an error? Like “Only continue if Status code = 200

I’m NOT a code head and have made this zap from reading the web.. 

icon

Best answer by Troy Tessalone 19 August 2022, 16:05

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

6 replies

Userlevel 7
Badge +14

Hi @JP Hansen 

Good question.

 

A Formatter > Text > Replace Zap step can be used to replace all matching characters: https://zapier.com/apps/formatter/help

Or a Code step can be used with regex (regular expression) to replace characters. (https://www.w3schools.com/jsref/jsref_replace.asp)

 

You can add a Filter step to the Zap to only continue when certain conditions are met: https://zapier.com/apps/filter/help

Hi @JP Hansen 

Good question.

 

A Formatter > Text > Replace Zap step can be used to replace all matching characters: https://zapier.com/apps/formatter/help

Or a Code step can be used with regex (regular expression) to replace characters. (https://www.w3schools.com/jsref/jsref_replace.asp)

 

You can add a Filter step to the Zap to only continue when certain conditions are met: https://zapier.com/apps/filter/help

Thanks for getting back.. I tried the filter step after the webhook.. This is not possible.. It say it needs something after the filter step - and the only thing I need is the step to fail if the API post fails.. :-/

Userlevel 7
Badge +14

@JP Hansen 

Webhook steps depend on the app API being used in terms of how that app handles responses.

Some apps will fail if the request is invalid.

Some apps will always return a “success” response but include an error message.

@Troy Tessalone I know.. It’s just impossible for me to know if the zap actually made it all the way.. The zap say Success but it failed to post because of bad request:

success
false
statusCode
400
message
Bad Request
data
name
Bad Request
message
Invalid JSON data in request body: Control character error, possibly incorrectly encoded.
code
0
status
400

And that is one part I dont understand.. 

And I have a really hard time figuring out what makes it fail.. it’s only some of them that fails..

@Troy Tessalone Could the json code fail because the comments field I add via variable to the code contains symbols and special characters like: påøæ+?=)(/&%

 

ooh and forgot to say it’s a “Custom Request” Webhook

Userlevel 7
Badge +14

@JP Hansen 

Sometimes it takes a process of elimination and to test different hypothesis to isolate the root issue.