shopify-api-ruby: Deleting a Product Image resource fails API v 3.4.2
Given a Product with Images we can iterate product.images
Given an instance of an image eg:
img = ShopifyAPI::Product.find(260391085).images.first
=> #<ShopifyAPI::Image:0x007fb4b9375bc0 @attributes={"created_at"=>"2014-03-08T20:37:26-05:00", "id"=>570863025, "position"=>1, "updated_at"=>"2014-03-08T20:37:26-05:00", "src"=>"https://cdn.shopify.com/s/files/1/0084/3892/products/calice1_2013.jpg?v=1394329046"}, @prefix_options={:product_id=>260391085}, @persisted=true>
We can see we get the parent product ID in the product_options attribute:
@prefix_options={:product_id=>260391085}
Trying to delete this image resource fails however.
ShopifyAPI::Image.delete(img.id)
ActiveResource::MissingPrefixParam: product_id prefix_option is missing
It would be nice to factor image resource deletes into the API.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 16 (10 by maintainers)
Commits related to this issue
- [amends https://github.com/Shopify/shopify_api/issues/138] Document alternate syntax for deleting an image with one api call — committed to kevinmpowell/shopify_api by kevinmpowell 9 years ago
- Adding meta files (#138) * Adding meta files — committed to Shopify/shopify-api-ruby by mohs 2 years ago
@resistorsoftware If you want a cleaner syntax option, try:
@resistorsoftware The following should work for deleting the image – if not please let me know :
cc: @pickle27 You were close! 😃
I think you just need to provide a product id and it will work the way you want. For example this is how we fetch an image directly using the api: