Best answer

Zapier not able to store json encoded string?

  • 24 January 2023
  • 2 replies

Userlevel 1

I am developing a Zap trigger that is pretty straight forward.  Event happens (let’s say a donation) → Zapier Code to parse a field → map output fields to another application.  One of the fields in the sending app contains some custom data, which is basically array of objects.  In the trigger webhook I encode this data as a json string.

In order to parse this out, I use the Zapier Code step.  I take the data from the field, run JSON.parse on it and then map the output fields.  All if this is working when I test the code step.  I am also able to test the final step and output to a sample spreadsheet.

All of this is failing on the Code step when I try it with an actual live Zap.  It appears that Zapier is automatically parsing the json encoded string and turning it into some wonky string format (like field 1 label value 2 label value).  I am definitely sending a json STRING in my trigger webhook.  Just for fun I sent two fields, one with raw json and the other with the json string and it displays both fields with the same “output” in the step before the Code step. 

As another test I added some dummy text in front of the json string.  Zapier at that point recognizes the incoming field as a string.  I then in the Code step split the string first and JSON.parse the remainder.  That ended up working but it’s an ugly hack.

Is there something I’m not aware of on how Zapier handles incoming json strings?  


Here is what I’m sending to my trigger:


This is what Zap creates as “output” before sending to my Code step which causes it to fail.  As you can see it’s exactly the same json encoded vs no json.



Best answer by Troy Tessalone 24 January 2023, 16:24

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.

2 replies

Userlevel 7
Badge +14

Hi @mistarjefe 

Good question.

Zaps will try to convert handle array line items in Zap step data.

There are some ways to work with this;

  1. Webhook - Catch Raw Hook
  2. Formatter > Utilities > Line Items to Text


Userlevel 1

If anybody is wondering what the solution to my particular issue is, read to the end.  None of this is clear and I was wracking my brain attempting to figure it out and was guided by a helpful Partner support person.

  • Pulling the recent record from a Zap trigger will show any fields with json encoded strings as...a string.
  • Using the field in subsequent steps will maintain the field as a string (for instance, testing a parsing function in a Code step or sending to another trigger) and cause all individual testing to pass.
  • Live Zaps for some reason do not behave like the tests and will transform the string into an array producing array line items, causing anything relying on that to fail.  You can check the failed run and see that your output from the previous step has now become an array line item instead of an encoded string.

Zapier apparently automatically parses json on every field and attempts to put it in the line item format even if it a string and only on a live Zap.  Solution is to return the raw request from the Partner application which bypasses this filtering.  In the perform section of a Partner app it’s typically 

return [bundle.cleanedRequest];

Which should now be

return [JSON.parse(bundle.rawRequest.content]);

Basically taking the raw request and running the content field through json parsing.  If you are not the app owner then you probably have to do the raw-hook method.