Hey everyone, I’m stuck with a problem while trying to add a product collection using the Shopify API. I’m using a PHP adapter, but I keep getting an internal server error (500) when I run my code.
Here’s what I’m trying to do:
$collection = [
'custom_collection' => [
'title' => 'Smartphones',
'collects' => [
'product_id' => 12345678
]
]
];
$result = $shopify_client->post('/admin/custom_collections.json', $collection);
When I run this, I get a ShopifyApiException with a 500 error. The response just says ‘Error’ without any more details.
I’ve double-checked my API credentials and they seem fine. Has anyone run into this before or know what might be causing it? Any help would be great. Thanks!
hey mikechen, sounds like a pain! have u tried using the separate endpoint for adding products to collections? something like ‘/admin/collects.json’ might work better. also, double-check ur product ID is valid. those 500 errors can be super frustrating. good luck!
I’ve dealt with similar issues before, and it can be incredibly frustrating. One thing that’s helped me is to break down the process into smaller steps. Try creating the collection first without adding products, then use a separate API call to add products to it. This approach has worked well for me in the past.
Also, make sure you’re using the latest version of the Shopify API. They sometimes make changes that can cause unexpected errors with older versions. If you’re still having trouble, it might be worth reaching out to Shopify’s developer support. They’ve been quite helpful when I’ve run into API-related roadblocks.
Lastly, double-check your API rate limits. If you’re making a lot of requests in a short time, you might be hitting a limit which could cause these kinds of errors. Good luck sorting it out!