Here's the solution for a bundle, quite complicated.
It is based on Magento2 (I see different tags, but I think, according to the error message, that you want it for Magento2).
Let's assume that our bundle is identified by the SKU "bundle01" and ID 123.
First of all, let's take some information from the product:
GET /products/bundle01?searchCriteria
and take note of the "extension_attributes" --> "bundle_product_options"
section, particularly to the option_id
fields related to your products. And take not of all the product_links
--> id
values related to the product.
Let's assume that we have 3 products with option_id 643, 644, 645 and id 704,705,706 respectively.
With all these information, here's the body to add a bundle product to your cart:
{
"cart_item": {
"quote_id": <quote_id>,
"sku": "bundle-01",
"qty": 1,
"product_option": {
"extension_attributes": {
"bundle_options": [{
"option_id": 643,
"option_qty": 1,
"option_selections": [704]
}, {
"option_id": 644,
"option_qty": 1,
"option_selections": [705]
}, {
"option_id": 645,
"option_qty": 1,
"option_selections": [706]
}]
}
}
}
}
You can refer to the offical swagger documentation : http://devdocs.magento.com/swagger/index_20.html#/
1/ You need to create a guest cart :
POST http://domain.com/rest/V1/guest-carts
Which return a guest cart id such as 881d962b14c14764a0f5939be4722cbc
.
2/ (Optional) Retrieve the quote id from this API call :
GET http://domain.com/rest/V1/guest-carts/881d962b14c14764a0f5939be4722cbc
Where a field id correspond to the quote id, for example "id": 31
.
3/ Add a product to your cart :
POST http://domain.com/rest/V1/guest-carts/881d962b14c14764a0f5939be4722cbc/items
The payload pattern is :
{
"cartItem": {
"itemId": 0,
"sku": "string",
"qty": 0,
"name": "string",
"price": 0,
"productType": "string",
"quoteId": "881d962b14c14764a0f5939be4722cbc",
"productOption": {
"extensionAttributes": {
"customOptions": [
{
"optionId": "string",
"optionValue": "string",
"extensionAttributes": {
"fileInfo": {
"base64EncodedData": "string",
"type": "string",
"name": "string"
}
}
}
],
"downloadableOption": {
"downloadableLinks": [
0
]
},
"giftcardItemOption": {
"giftcardAmount": 0,
"customGiftcardAmount": 0,
"giftcardSenderName": "string",
"giftcardRecipientName": "string",
"giftcardSenderEmail": "string",
"giftcardRecipientEmail": "string",
"giftcardMessage": "string",
"extensionAttributes": {}
},
"configurableItemOptions": [
{
"optionId": "string",
"optionValue": 0,
"extensionAttributes": {}
}
],
"bundleOptions": [
{
"optionId": 0,
"optionQty": 0,
"optionSelections": [
0
],
"extensionAttributes": {}
}
]
}
},
"extensionAttributes": {}
}
}
An example for a basic configurable product :
{
"cartItem": {
"sku": "ProductSKU",
"qty": 1,
"quoteId": "881d962b14c14764a0f5939be4722cbc",
"productOption": {
"extensionAttributes": {
"configurableItemOptions": [
{
"optionId": "178",
"optionValue": 45,
"extensionAttributes": {}
}
]
}
}
}
}
Magento uses both cartId and quoteId that referece on different internal id.
Best Answer
In case you still need it.
Let's assume that our bundle is identified by the SKU "bundle01" and ID 123.
First of all, let's take some information from the product:
GET /products/bundle01?searchCriteria
and take note of the
"extension_attributes" --> "bundle_product_options"
section, particularly to theoption_id
fields related to your products. And take not of all theproduct_links
-->id
values related to the product.Let's assume that we have 3 products in the bundle, with option_id 643, 644, 645 and id 704,705,706 respectively.
With all these information, here's the body to add a bundle product to your cart: