Best answer

Getting data from Webhooks into Code by Zapier

  • 14 October 2020
  • 2 replies

Userlevel 2

I have a Webhook by Zapier step that is a GET request for some data to an API. It returns all of the data just fine.

The JSON that the API returns is quite a big object and I need to access this entire object in the next step in my Zap which is a “Code by Zapier” step running JavaScript.

While there is an “input Data” option where I can set the key/value’s from the GET request step, I cannot figure out how to simply set the whole object to something like this:

getRequestData = {
"one": "big",
"object": "here"

How can I set the entire JSON to a variable inside this step so that I can use it in there or do I really have to rebuild this entire object by adding potentially hundreds of things to the `inputData`? This would be problematic because it’s time consuming, but more so because if this object’s shape ever changes I need to update all of the input data again… 

I have tried making the GET request in the code step itself, however it bombs out and I don’t get any errors back from Zapier - I’m assuming it’s some sort of CORS issue.

I appreciate any help!


Best answer by Troy Tessalone 14 October 2020, 21:20

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

You can try making an API request in a Code step:

Userlevel 2

You can try making an API request in a Code step:

I just updated my question with those details - but this is something I have tried. However when I send the request using the fetch API and I throw an authorization bearer token header in and then I try and log the result (`const result = await response.json()` then `console.log(result)` I never get anything in the logs, nor do I get any errors returned from Zapier. Something is bombing out and not getting swallowed up by Zapiers error handling :( 

If I do this same logging for a POST that I am sending using the fetch api I actually get my result logged...