Show “You need to choose options for your item” message in magento2.2 when I hit API for add to cart configrable product
-
13-12-2020 - |
Question
This is on Magento official document
http://devdocs.magento.com/guides/v2.2/get-started/order-tutorial/order-add-items.html
magento-host/rest/default/V1/carts/mine/items
parameters
{
"cartItem": {
"sku": "MH01",
"qty": 1,
"quote_id": 4,
"product_option": {
"extension_attributes": {
"configurable_item_options": [
{
"option_id": "93",
"option_value": 52
},
{
"option_id": "141",
"option_value": 168
}
]
}
},
"extension_attributes": {}
}
}
Show response "message": "You need to choose options for your item.",
Solution
Check attribute id which you are using in api is valid or not.
{
"cartItem": {
"sku": "MH10",
"qty": 1,
"quote_id": "25",
"product_type" : "configurable",
"product_option": {
"extension_attributes": {
"configurable_item_options": [
{
"option_id": "93",
"option_value": 51
},
{
"option_id": "147",
"option_value": 169
}
]
}
}
}
}
You can use above code for configurable product add in cart. It's working well in my side.
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange