Skip to main content

Hello guys,

I’m facing a probably simple problem. I’m building a form that sends the data thru a webhook as JSON. The problem is that if the end user completes the form and uses quote symbols the webhook will error out and the zap will halt.

 

How can I remove any quote symbols or anything that could error out when sending a JSON payload?

@robertbant can you post a sample of the payload from the raw catch hook please?


Here is the setup for the Catch Raw Hook…

 

Let’s say your raw JSON is:

{"key":""value""}

Here is the code to parse it:

//Take the rawJson input and replace all instances of double quotes with single quotes
var rawJson = inputData.rawJson.replace(/\:\"\"/g, ':"' + "'").replace(/\"\"/g,"'" + '"');

//Parse the rawJson and return the result
return {json: JSON.parse(rawJson)}

Here is how the result would look:

 

Hey Craig,

I just noticed that the data is coming using the involve.me app like this:

key=value

 


Here is the setup for the Catch Raw Hook…

 

Let’s say your raw JSON is:

{"key":""value""}

Here is the code to parse it:

//Take the rawJson input and replace all instances of double quotes with single quotes
var rawJson = inputData.rawJson.replace(/\:\"\"/g, ':"' + "'").replace(/\"\"/g,"'" + '"');

//Parse the rawJson and return the result
return {json: JSON.parse(rawJson)}

Here is how the result would look:

 


@robertbant you can try changing the Webhook trigger action to “catch raw”. If you do that, Zapier won’t parse the JSON from your request. However, you’ll still need to manually parse it in the next step in order to get the data as fields. The best way to do that is to use a Code By Zapier action, replace the double quotation marks in your raw JSON string with single quotation marks, then do a JSON.parse(jsonstring) to turn your raw JSON string into an object with fields, which can be returned for other steps. 

 

Thanks for the answer Craig.

 

The thing is, there shouldn't be any quotation marks, what im trying to do is an insurance, if someone puts quotation marks to be removed.

 

Also, can you share a code exemple how to remove or change the quotation marks?


@robertbant you can try changing the Webhook trigger action to “catch raw”. If you do that, Zapier won’t parse the JSON from your request. However, you’ll still need to manually parse it in the next step in order to get the data as fields. The best way to do that is to use a Code By Zapier action, replace the double quotation marks in your raw JSON string with single quotation marks, then do a JSON.parse(jsonstring) to turn your raw JSON string into an object with fields, which can be returned for other steps. 


Nobody has a solution?