Error: An array is expected

Error shown

When you add a polling trigger or search action to your integration, the Zapier platform expects a bare array of new or found items returned, sorted in reverse chronological order. An API may instead return a result object that contains the array of items the trigger/search needs.

For example, for a “Find Issue” search action with GitHub’s API, we might start with a https://api.github.com/repos/{{bundle.inputData.owner}}/ {{bundle.inputData.repo}}/issues/{{bundle.inputData.issue_number}} request:

When tested, Zapier will show an error message Results must be an array, got: object,

Check the API response in the HTTP tab of the Test your API Request section, and you’ll see an object that contains the array of items we need was returned, not the array itself:

Solution

Instead, return that array of channels to Zapier. To do that switch to Code Mode in your request. That will allow you to provide a JavaScript function to handle the request, and make needed changes to the structure or content of the result before returning data to the Zapier platform.

For this request, wrap the response with an array instead of the default return results, to have Zapier return an array of issues.

Remember: Code Mode is a toggle; if you switch back to Form Mode your code will be ignored!

Now, retest the request and it should run successfully.


Need help? Tell us about your problem and we’ll connect you with the right resource or contact support.