Question

HELP! How do you parse webhooks data as number instead of a string


Userlevel 1

I am trying to send data to an application not currently supported by Zapier via the POST webhooks zap. 

Everything works fine except for number fields, which got me thinking… 

If i wanted to send data as a string or as a number, how would i distinguish them in the datafields? 

eg lets say i wanted Zapier to read ‘duration’ as a string and ‘duration-2’ as a number. 

How can i distinguish this in the set up? 

My problem is that i need to input a number value but Zapier seems to parse the data as a string. 

What can i do to make it read it as a number? 

 

 


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

11 replies

Userlevel 7
Badge +14

Hi @Strem 

Good question.

You can use the Webhooks Custom Request option to configure the JSON.

 

Userlevel 1

I’m actually having some trouble validating headers with custom request, so ideally i’m looking for a solution that does not go down this route. But maybe not possible? Seems strange tho

Userlevel 7
Badge +14

@Strem 

If you’re using POST Request or Custom Request, the Headers section in the Zap step config is the same.

Userlevel 1

For whatever reason when I test a Zap using Custom Request and i use the exact same Header config as a POST Request, the test fails citing Invalid Headers (HTTP Status Code: 400)

Userlevel 7
Badge +14

@Strem 

We’d need to see updated screenshots with how your Zap step is configured to have context.

Userlevel 1

Sure. 

Here are the two configs. Note the basic required info for this API is simply name and workspaceID, so these are the only elements i am including for now in the CUSTOM REQUEST. But you can see that the Header is the same. 

POST REQUEST and Test Result
 

 



Here is the CUSTOM REQUEST and Test result. 

 

 


Headers is the same on both. One passes authorisation and the other doesn’t 

Userlevel 7
Badge +14

@Strem 

You need to put double quotes around the fields and values.

“name” : “[VARIABLE]”;

“workplaceId” : “VALUE”

 

 

Userlevel 1

Added double quotes to name and value 

still getting same Invalid Headers error. 

 

 

 

Userlevel 7
Badge +14

@Strem 

Try adding these headers:

Accept: application/json

Content-Type: application/json

 

You can try testing your API request in Postman, which may provide more context about the error.

Userlevel 1

Troy, you are a legend! Works! Thanks for being patient and helping solve the issues

Userlevel 7
Badge +11

This is what I love to see! 

@Strem I just wanted to confirm whether you’re now good to go with the Webhook step.

It’s awesome seeing the interaction here, and Troy sure is a legend when it comes to digging into the nitty gritty of Zapier, APIs and code 😀