For the Zapier App that I am developing, I am configuring a Trigger of type REST Hook.
Say that my API returns details about soccer matches. The format of the data that gets posted to Zapier by my API would look something like this:
"player_name": "Lionel Messi",
"player_name": "Lionel Messi",
I want to be able to allow a user of my App to consume all the output fields available from my API, including `goals` and `penalties`. When I try to specify these output fields, they don’t seem to be available when I try to create a new Zap.
How do I add these fields?
Best answer by jamesanselmView original
To clarify, my use case isn’t for soccer games. I used it as an example.
@jamesanselm - Thank you for your question! So that we can get you the right type of support, we kindly ask that you direct all developer support questions to our Support team directly: http://zpr.io/t4NNK - This helps us get an accurate capture of your account details so that we may assist you quickly. Thank you for understanding!
For example, here’s a screenshot of my trigger in code mode on the Developer Platform you’ll see I’m doing very little processing to the results, just grabbing a sub-object/array to return to the zap.
Are you doing any parsing like that?
I had posted my question on StackOverflow as well. https://stackoverflow.com/questions/62643662/zapier-rest-hook-trigger-how-do-you-include-a-variable-size-array-output-fie
It used to look something like this:
As a workaround to allow users of my Zap to use the goals and penalties however they want, I have modified the Perform function to look something like this:
This way, a user of my Zap would then have to use a Code By Zapier step to reconstruct the goals or penalties array as they were returned by my API, using code such as:
Could you change the trigger to just return the top-level information about the games (total minutes, final score, who played etc) and then have an action step that gets the goals for a specific game and another action step that gets the penalities for a specific game.
This is far from ideal, but It would keep your users from having to do any code steps. We often have to do this when there’s a new invoice, follow up by getting the contact record and the product record to get information thats not available in the trigger step.
My code for the API Endpoint looks something like this:
@PaulKortman! Hope you had a nice long weekend. Would it be possible to take a look at my latest reply?
@jamesanselm have you been able to solve this? Maybe can you clarify the current issue with an output example.
@ForYourIT . I followed up with the Zapier developer support team through email. It is currently expected that if a Zapier Action is configured with an API endpoint that may return multiple results, then the Zapier Action will only return the first result.
For my example Zapier Action that attempted to retrieve the goals from a game (https://community.zapier.com/developer-discussion-13/how-do-you-include-a-variable-size-array-output-field-in-the-output-data-returned-by-a-trigger-3158?postid=12383#post12383), the output would be the object `games.goals`.