I’m trying to create a custom collection using a PHP library for Shopify API but keep getting a 500 Internal Server Error. Here’s my code:
define('STORE_DOMAIN', 'mystore.myshopify.com');
define('API_KEY', 'your_api_key_here');
define('API_PASSWORD', 'your_password');
define('SHARED_SECRET', 'your_secret');
require 'shopify_lib/client.php';
$client = shopify_api_client(STORE_DOMAIN, NULL, API_KEY, API_PASSWORD, true);
try {
$collection_data = array(
"custom_collection" => array(
"title" => "Electronics",
"collects" => array(
"product_id" => 12345678
)
)
);
$result = $client('POST', '/admin/custom_collections.json', $collection_data, $headers);
echo "API calls made: " . shopify_calls_made($headers);
echo "Calls remaining: " . shopify_calls_left($headers);
} catch (ShopifyApiException $error) {
print_r($error);
}
The error shows HTTP status 500 with the message “Internal Server Error”. The response just says “errors: Error” without more details. I’m not sure if the problem is with how I’m structuring the collection data or if there’s something wrong with my API credentials. Has anyone else run into this issue when creating collections through the Shopify API? What could be causing this server error?