Shopify API Gem Error when creating custom collection collects.shop_id can't be blank

Highlighted
Shopify Partner
14 0 3

This is the error I'm getting:

POST https://redacted.myshopify.com:443/admin/custom_collections.json
--> 422 Unprocessable Entity 88 (193.4ms)
Request:
{"custom_collection":{"title":"Redacted","collects":[{"product_id":9056559118},{"product_id":9065880270},{"product_id":8255843459},{"product_id":8255888707},{"product_id":8255943939},{"product_id":9056987470},{"product_id":9057523150}]}}
Headers: {"Authorization"=>"Basic YWVlYTAzNDJmNDljYzM1NTNlODU4MGQzMGE3YmY5Zjg6YzVlYzIwZGU3NDU5NTQ3MzRhNTQzZWI5N2RmODRiYmM=", "Content-Type"=>"application/json", "User-Agent"=>"ShopifyAPI/4.3.0 ActiveResource/4.1.0 Ruby/2.3.0"}
Response:
{"errors":{"collects.shop_id":["can't be blank"],"collects.product":["can't be blank"]}}

I can't find anything in the API Docs about needing to set a shop_id or a product when creating a custom collection. https://help.shopify.com/api/reference/customcollection

Anybody know what's wrong with my request?

0 Likes
Highlighted
Shopify Staff
Shopify Staff
291 3 59

Hey Kevin,

This is not an API related error rather an issue with the shop. I would recommend contacting the account owner of that shop.

 

- Jordan

0 Likes
Highlighted
Shopify Partner
14 0 3

I am the account owner of the shop. Can you tell me how to resolve the issue?

0 Likes
Highlighted
Shopify Partner
14 0 3

For future reference. This was not an API related error, it was an issue of out of sync data. The product_id I was passing on the API request no longer existed in my store. In my case I was passing a couple hundred product_id's in on creation of the CustomCollection and only a few of them no longer existed. Took some debugging, but if you run into that error message, that's likely your problem.

0 Likes
Highlighted
New Member
3 0 0

This means there is a product id in the list of collects that does not exist in the shop anymore.

I wish the error was more clear and told you the product id that should be removed.

Throw the error saying these products dont exist and then list the ids.

Otherwise, the client has to go back and confirm each product id, find the one that does not exist and then resend the request. Sometimes that is 1000s of products in the collection.

 

0 Likes