Actual url
PUT /V1/carts/81/items/1
Post body
{
"cartItem":{
"qty":1
}
}
Response
{
"message": "No such entity with %fieldName = %fieldValue",
"parameters": {
"fieldName": "cartId",
"fieldValue": null
}
}
@pborges Thank you for reporting this.
Please try adding a quoteId param to the request body, e. g:
PUT /V1/carts/81/items/1
{
"cartItem": {
"qty": 10,
"quoteId": 81
}
}
We have an internal ticket with id MAGETWO-46732 to fix id duplication in such cases.
That did not work for me, this is the error I get now
{
"message": "Cart %1 doesn't contain item %2",
"parameters": [
"81",
1
]
}
It looks like its trying to display that item rather than attach?
I am using a PUT request
@pborges PUT /V1/carts/:cartId/items/:itemId is used to update the item.
If you wish to add another item to the cart please refer to POST /V1/carts/:cartId/items.
Ok, I will try that. However the swagger documentation says
Put /V1/carts/{cartId}/items/{itemId}
description: "Adds the specified item to the specified cart."
operationId: "quoteCartItemRepositoryV1SavePut"
@pborges Thanks, we will check and fix documentation on this topic.
@pborges did you manage to solve this via post ? It give same response with post, as if it is trying to update the product
@pborges @userException
To add an item to the existing cart you may use the following:
POST /V1/carts/:cartId/items
{
"cartItem": {
"sku": "simple",
"quoteId": 1,
"qty": 1
}
}
@userException post worked perfectly providing the item is "In Stock"
@pborges @ishakhsuvarov This worked for me..
Also, I was trying to update the product in the cart. How can I decrease the quantity? I tried sending -1 in "qty" parameter via a PUT request but it increased the quantity.
And deleting the product removes the whole product and does not decrease the quantity, which is correct. But what can be used for updating a product in the cart.
@userException To update the item in cart please try the following:
PUT /V1/carts/:cartId/items/:itemId
{
"cartItem": {
"itemId": 1,
"qty": 10,
"quoteId": 1
}
}
You may obtain the list of items and their itemId for the specific cart using GET /V1/carts/:cartId/items.
@ishakhsuvarov @pborges Thanks this solved my issue ! Can you help me with this one: https://github.com/magento/magento2/issues/2773
@ishakhsuvarov the documentation here http://devdocs.magento.com/swagger/index.html still says "Implementation Notes Add the specified item to the specified cart." for the PUT method
how can we add configurable or bundle product to cart ?
Is there any update with this? I am working with Magento ver. 2.1.7.
If I try PUT '/V1/carts/{cartId}/items/10 with this body:
{
"cartItem":{
"qty":1,
"quoteId": 70
}
}
I get
{
"message": "Cart %1 does not contain item %2",
"parameters": [
"70",
10
]
}
PUT '/V1/carts/70/items/10' with this body:
{
"cartItem":{
"qty":1
}
}
gets me this:
{
"message": "No such entity with %fieldName = %fieldValue",
"parameters": {
"fieldName": "cartId",
"fieldValue": null
}
}
POST '/V1/carts/70/items/10' with this body:
{
"cartItem": {
"sku": "TRAINING-MAGENTO-STOREMG",
"qty": 1
}
}
gets me this:
{
"message": "No such entity with %fieldName = %fieldValue",
"parameters": {
"fieldName": "cartId",
"fieldValue": null
}
}
So, basically, I haven't discovered a way to add an item to a cart.
In Post you need to include quoteId
Thanks for your help. What I had to do was:
POST '/V1/guest-carts'
(no body)
It returns something I will call a sCartKey. Mine looks like this: 8ea31b655a5ea0be566b9722f831b77a
To put iQty item(s) with the sku sSku in the cart:
POST '/V1/guest-carts/{sCartKey}/items'
with this body:
{
"cartItem": {
"sku" : sSku,
"qty" : iQty,
"quote_id" : sCartKey
}
}
Hi I am still encountering the above error. I am using POST request with the following parameters in the body section
{"data":{"cartItem":{"productOption":{"extensionAttributes":{"customOptions":[]}},"qty":1,"quote_id":"1507026","sku":"FTW122019B3541","price":225}},"cartId":"1507026"}
And I get the following output
{ "message": { "message": "No such entity with %fieldName = %fieldValue", "parameters": { "fieldName": "cartId", "fieldValue": null } } }
Any help?
Most helpful comment
@userException To update the item in cart please try the following:
PUT /V1/carts/:cartId/items/:itemIdYou may obtain the list of items and their
itemIdfor the specific cart usingGET /V1/carts/:cartId/items.