I'm using Zapier to POST into a Keen stream via a webhook, but my values are being sent to Keen as strings, e.g., {"amount": "50"}. Is there a way for me to get Keen (or Zapier) to cast "50" as an int (50)?
1 Answers
The Zapier "POST" action automatically coerces all values to strings, so you'll want to do something a bit different here. I suggest using the Custom Request action instead of the POST action. This action allows you to specify the raw JSON payload. You can find it if you click "show less common options".
Here's an example request that worked:
Method
POST
URL
https://api.keen.io/3.0/projects/<projID>/events/ScheduledZap2?api_key=<key>
Data
{"first_name": "Steve", "last_name": "Juth", "amount": 59, "state": "NJ"}
Unflatten
yes
Headers
Content-Type
application/json
Optional fields without a value
Data Pass-Through?
Basic Auth
Essentially a custom request (POST) in Zapier allows you to custom build the JSON string sent to Keen, which allows you to drop double quotes for int values.
When dealing with longer strings, say from a textarea in an HTML form that gets sent into a Zap, beware of newlines, which will break this integration. Zapier provides a way to replace newlines with spaces by using its Formatter, choosing the Text option, and replacing [:newline} with [:space].

- 734
- 4
- 16