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

在Zapier中使用JS调用Ebay API失败问题排查请求

Ebay Finding Service API在Zapier Fetch JS中调用失败的排查方案

问题还原

我有一个能在Postman正常运行的Ebay沙箱API调用:

https://svcs.sandbox.ebay.com/services/search/FindingService/v1?Operation-Name=findItemsByKeywords&Service-Version=1.0.0&Security-AppName=PetrosBe-Sells-SBX-9ac2147f3-b674cf2c&Response-Data-Format=JSON&REST-Payload&keywords=laptop

但在Zapier中用以下Fetch JS代码调用时出错:

const newOptions = {    
    //...options,
    headers: {
        'Content-Type': 'application/json',
        'Authorization': `My Auth ID`,
    },
}
const res = await fetch('https://svcs.sandbox.ebay.com/services/search/FindingService/v1?Operation-Name=findItemsByKeywords&Service-Version=1.0.0&Security-AppName=xxx&Response-Data-Format=JSON&REST-Payload&keywords=laptop', newOptions);
const json = await res.json();
return json;

核心问题分析

  • 多余请求头引发的错误:Ebay Finding Service的沙箱GET请求不需要Authorization头,Postman能成功是因为没有额外添加该头,而Zapier代码里的Authorization会被API判定为无效凭证;同时Content-Type: application/json头也完全多余——GET请求没有请求体,添加这个头会让API误解请求格式。
  • 请求方法可能被覆盖:Fetch默认用GET,但如果//...options里隐含了POST方法,会和Postman的请求方法不匹配,导致调用失败。

修正后的代码

// 移除多余headers,使用纯GET请求
const res = await fetch('https://svcs.sandbox.ebay.com/services/search/FindingService/v1?Operation-Name=findItemsByKeywords&Service-Version=1.0.0&Security-AppName=PetrosBe-Sells-SBX-9ac2147f3-b674cf2c&Response-Data-Format=JSON&REST-Payload&keywords=laptop');
const json = await res.json();
return json;

额外检查点

  1. 确保Security-AppName参数替换为自己的沙箱App ID(代码里的xxx要换成实际有效ID)
  2. 如果需要保留部分配置项,要明确指定method: 'GET',避免默认方法被覆盖
  3. 可以在Zapier中添加错误捕获,查看具体报错信息:
    try {
      const res = await fetch('你的API地址');
      if (!res.ok) {
        throw new Error(`HTTP错误状态: ${res.status}, 响应内容: ${await res.text()}`);
      }
      const json = await res.json();
      return json;
    } catch (error) {
      return { error: error.message };
    }
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.24 02:12:42