1

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" } } 
0

2 Answers 2

1

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

0

here is the swagger documentation of Magento2 Rest endpoints, please search for quoteGuestCartItemRepositoryV1, there are some helpful examples, data structure etc.

swagger doc

Thanks.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.