Delete an option via API

Solved
Jerry54000
Tourist
8 1 0

Hello Everyone,

My product variants have 2 options. I want to delete one of them, so I execute this command in the shopify-api console:

product.options[1].destroy

but I get this error message

E, [2021-10-08T20:46:13.078147 #13713] ERROR -- : DELETE https://devsystem.myshopify.com:443/admin/api/2021-07/options/.json

E, [2021-10-08T20:46:13.078207 #13713] ERROR -- : --> 406 Not Acceptable 0 (423.4ms)

ActiveResource::ClientError: Failed.  Response code = 406.  Response message = Not Acceptable.

product.options[1].errors.full_messages.to_sentence returns an empty string. So I have no idea what's causing the error.

My question is how do I delete a product option via API?

Thanks for your help.

Regards,

Jerry.

Accepted Solution (1)

Accepted Solutions
Jerry54000
Tourist
8 1 0

This is an accepted solution.

Oh after a few more tinkering I figured it out.

product.options.pop(1)

product.save

After this I'm only left with one option.

View solution in original post

Reply 1 (1)
Jerry54000
Tourist
8 1 0

This is an accepted solution.

Oh after a few more tinkering I figured it out.

product.options.pop(1)

product.save

After this I'm only left with one option.