I’m having trouble setting up a custom collection through the Shopify API using a PHP wrapper library. I can successfully retrieve product data and cart information, but when I try to create a new collection with specific product IDs, it keeps failing.
$collection_data = array(
"custom_collection" => array(
"title" => "MyNewCollection",
"collects" => array(
"product_id" => 12345678,
"product_id" => 87654321
)
)
);
try {
$result = $shopify_api('POST', '/admin/custom_collections.json', $collection_data, $headers);
echo "Calls made: " . shopify_calls_made($headers);
echo "Calls remaining: " . shopify_calls_left($headers);
} catch (ShopifyApiException $error) {
echo "Request failed";
var_dump($error);
}
The API returns a 500 Internal Server Error with just a generic “Error” message. Other API operations work fine, so I think there might be an issue with how I’m structuring the collection data. Has anyone successfully created collections this way? What am I missing in the request format?