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"
 }
}
Jjo
1,1788 silver badges17 bronze badges
asked Jul 13, 2017 at 8:51
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

answered Oct 2, 2017 at 13:18
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.

answered Jul 14, 2017 at 16:49

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.