1
我一直在嘗試使用Shopify API添加新的自定義集合。但不斷獲得標題的錯誤不能爲空。Shopify API:創建新自定義集合時出錯。 {「errors」:{「title」:[「can not be blank」]}}
雖然已經被設置在POST領域標題
我的代碼如下:
$url = 'https://APIKEY:[email protected]/admin/custom_collections.json';
$collection = array
(
"custom_collection" => array('title' => 'Made In the USA')
);
// $payload = json_encode($collection);
$payload = '{
"custom_collection": {
"title": "IPods",
"collects": [
{
"product_id": 99395358
}
]
}
}';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_USERAGENT, 'HAC');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $payload);
$return = curl_exec($ch);
curl_close($ch);
我得到響應
{"errors":{"title":["can't be blank"]}}