Problem: Images Are Not Being Deleted From Products
I have the following custom function in Python to communicate with the Shopify REST API via requests to delete images from products:
headers = {"Accept": "application/json", "Content-Type": "application/json"}
def delete_product_image(shop_url, product_id, image_id,headers):
del_r = requests.delete(f'{shop_url}/products/{product_id}/images/{image_id}.json()',headers=headers)
if del_r.status_code in [200, 201]:
print(f'image {image_id} of product {product_id} removed')
else:
print(f'Error: {del_r.status_code} - {del_r.text}')
time.sleep(1)
delete_product_image(shop_url, product_id, image_id)
When I execute the delete_product_image(shop_url, product_id, image_id,headers)
function, the del_r
status code returns 200
, but the images are not deleted from the products.
What is causing this issue?