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

Shopify REST API按订单项履约失败,返回Not Found错误求助

问题分析与解决

核心错误点1:API端点使用错误

你当前调用的POST端点https://bforbay.myshopify.com/admin/api/2023-10/fulfillments.json是旧版创建履约的接口,不适用于通过**履约订单ID(fulfillment_order_id)**创建履约的场景。Shopify针对履约订单的履约操作,要求使用专属端点:

POST /admin/api/2023-10/fulfillment_orders/{fulfillment_order_id}/fulfillments.json

需要把URL替换为对应履约订单ID的专属路径,而非根路径的fulfillments.json。

核心错误点2:履约订单ID与订单ID混淆

你用GET请求https://bforbay.myshopify.com/admin/api/2023-04/orders/5749831630946/fulfillment_orders.json返回空数组,说明5749831630946并不是订单ID,而是你误当作订单ID的履约订单ID。正确流程是:

  • 先通过真实订单ID调用/orders/{order_id}/fulfillment_orders.json,获取该订单下的履约订单列表
  • 从返回的fulfillment_orders数组中提取有效的履约订单ID,再用于后续的履约创建请求

额外排查点

  • 确认测试订单状态:仅已付款、已确认的订单会生成履约订单,未付款/未确认的订单不会有履约订单数据
  • 统一API版本:你POST请求用2023-10版本,GET请求用2023-04版本,建议使用同一版本避免兼容性问题

修正后的示例请求

假设已获取到有效的履约订单ID为xxxxxx,修正后的PHP代码如下:

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://bforbay.myshopify.com/admin/api/2023-10/fulfillment_orders/xxxxxx/fulfillments.json',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{"fulfillment": {"line_items_by_fulfillment_order": [{"fulfillment_order_id": xxxxxx, "fulfillment_order_line_items": [{"id": 13418123853922, "quantity": 1 }]}],"tracking_info": {"number": "AWEADSF898","url": "https://www.my-shipping-company.com?tracking_number=MS1562678"}}}',
  CURLOPT_HTTPHEADER => array(
    'X-Shopify-Access-Token: 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',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);
curl_close($curl);
echo $response;

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.04 16:32:54