You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Zapier搜索功能报错:期望返回数组却得到对象的技术咨询

Fixing "Results must be an array, got: object" in Zapier Search Action

Hey there, the error you're hitting is a simple format mismatch: Zapier requires search operations to return an array of results, but your custom API sends back a single JSON object. Even if you only ever expect one matching item, Zapier needs that result wrapped in an array to process it correctly.

The Quick Fix

Modify your perform function to wrap the parsed API response in an array. Here's the adjusted code:

module.exports = {
  key: 'item',
  noun: 'itemexists',
  display: {
    label: 'Find an item',
    description: 'check if item exist'
  },
  operation: {
    inputFields: [
      {
        key: 'itemid',
        type: 'string',
        label: 'itemid',
        helpText: 'Eg. e3f1a92f72c901ffc942'
      }
    ],
    perform: (z, bundle) => {
      const url = 'http://IP:8081/v1/itemexists/';
      const options = {
        params: {
          itemId: bundle.inputData.itemid
        }
      };
      // Wrap the parsed response object in an array
      return z.request(url, options)
        .then(response => [JSON.parse(response.content)]);
    },
    sample: {"exists": true, "data": {"creationDate": "2019-05-23T10:11:18.514Z", "Type": "Test", "status": 1, "Id": "456gf934a8aefdcab2eadfd22861", "value": "Test"}},
  }
};

Optional Adjustment (If You Only Need the data Field)

If you don't need to pass the exists flag to Zapier and just want the item details, you can tweak the return line to pull out the data property instead:

return [JSON.parse(response.content).data];

Just make sure your sample object is updated to match this structure if you go this route—Zapier uses the sample to generate previews and map fields.

内容的提问来源于stack exchange,提问作者TechChain

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 06:40:11