There is no direct connection to the "Custom Options" in a product and an attribute. You would have to simulate this manually. Follow these steps to do that:
Lets say you have a Category called Electronics. And an Attribute Set called Electronics.
Create a new attribute called whatever your Custom Option is, such as Extended Warranty.
When creating the Attribute, under Attribute Properties set Catalog Input Type for Store Owner and select either Dropdown, Multiple Select, or Price. Those are the only ones usable for filterable search.
Then in Frontend Properties select "Use In Layered Navigation".
Then click Manage Label/Options and input the options you would have in the Custom Options of the product.
Add this Attribute to the Electronics Attribute Set.
If you selected Dropdown as Catalog Input Type for Store Owner, then do the same for your Custom Options in the product. So if you had an Electronic, it now has the dropdown attribute for Extended Warranty or whatever attribute you want to use.
I run into the same issue. After some debugging I found out that the values are used as an array index (e.g. debug the $object->toArray() in Magento\Framework\Model\ResourceModel\Db\AbstractDb::prepareDataForUpdate). At this place the information about the default value and sort order are already removed when using integers as value.
So easily do not use integers as values at this place. When using the backend to create/update an attribute manually, magento uses "option_1", "option_2" and so on for values.
Applied to your example, this would result in:
{
"option": {
"label": "Cappuccino",
"value": "option_6"
}
}
OT but related: Create an Attribute:
When using POST /rest/V1/products/attributes to create an attribute having the options given, the options also won't be saved when using integers as values.
Best Answer
I've found out how to get list options I was looking for, it's possible to get attributes groups with array with options like so:
Where
31
is the attribute_group_id of custom attribute groupMISC