i want to know the magento 2 rest api for add product to cart
am trying
post /rest/V1/guest-cart and am getting cart_id then
post /rest/V1/:card_id/items in postman and am getting error like
{
"message": "%fieldName is a required field.",
"parameters": {
"fieldName": "cartItem"
}
}
Best Answer
This way only for registered customers:
Request path - http://127.0.0.1:8000/rest/V1/carts/3/items
Where 3 is your cart id
Method: POST
BODY: { "cartItem" : { "sku": "24-MB01", "qty": "1", "quote_id": 3 } }
Cart Id ( quote_id ) you can retrieve via:
http://127.0.0.1:8000/rest/V1/customers/1/carts
Method: POST
The response will be similar to:
"3"
Checked via Postman