我正在尝试通过将以下参数传递到/ 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(https://shopify.dev/docs/admin-api/rest/reference/shipping-and-fulfillment/fulfillment)。当我使用上述参数执行它时,我得到以下响应
[response] => {"errors":{"line_items":"expected Hash to be a Array"}}
仅当line_items
在数组中时,此问题才起作用。我想完成订单中的一些项目。有谁有想法吗?这是Shopify端的问题吗?
答案 0 :(得分:1)
您好,您必须在标头中进行设置并将参数作为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) );