shopify错误“;第“U项”行:&引用;期望散列为数组;当尝试创建实现时

shopify错误“;第“U项”行:&引用;期望散列为数组;当尝试创建实现时,shopify,Shopify,我试图通过将以下参数传递到/admin/api/2020-07/orders/{order_id}/fulfillments.json来创建行项目实现 { "fulfillment": { "location_id": 905684977, "tracking_number": null, "line_items": [ { "id": 46

我试图通过将以下参数传递到/admin/api/2020-07/orders/{order_id}/fulfillments.json来创建行项目实现

{
  "fulfillment": {
    "location_id": 905684977,
    "tracking_number": null,
    "line_items": [
      {
        "id": 466157049
      },
      {
        "id": 518995019
      },
      {
        "id": 703073504
      }
    ]
  }
}

以上参数直接来自shopify doc()。当我使用上述参数执行它时,我得到以下响应

 [response] => {"errors":{"line_items":"expected Hash to be a Array"}} 

只有当
行\u项
在数组中时才会出现问题,否则它将正常工作。我想完成订单中的几个项目。有人知道吗?这是Shopify端的问题吗?

您好,您必须在标题中设置这一点,并将参数作为json发送 试试这个:

$request_headers[] = "X-Shopify-Access-Token: " . $token;
$request_headers[] = "Content-Type: application/json" ;

curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
curl_setopt($curl, CURLOPT_POSTFIELDS,  json_encode($query) );

只需检查您的内容类型标题是否设置为发送数据的内容。另外,尝试将其作为字符串而不是JSON对象发送。