3

1.Created a guest cart (this will give me the cartID)-> POST: http://.../Magento2/index.php/rest/V1/guest-carts

  1. Get cart details-> GET: http://.../Magento2/index.php/rest/V1/guest-carts/{cartID}.

  2. add items to cart-> POST: http://.../Magento2/index.php/rest/V1/guest-carts/{cartID}/items

Added in body part. { "cartItem": { "item_id": 0, "sku": "string", "qty": 0 } }

Getting Error :- { "message": "No such entity with %fieldName = %fieldValue", "parameters": { "fieldName": "cartId", "fieldValue": null },

Thanks in advance.

For ref. Testing in postman client & using http://devdocs.magento.com/swagger/index.html#/ link.

2 Answers 2

6

Add item to guest cart

[POST] http://.../Magento2/index.php/rest/V1/guest-carts/ - gives cart Id.

[POST] http://.../Magento2/index.php/rest/V1/guest-carts/a03da1c69a5b1b57a405d05a31e16ce5/items – Adds an item to cart.

Body - { "cartItem": { "quote_id": "a03da1c69a5b1b57a405d05a31e16ce5", "sku": "Mobile1", "qty": 10 } }

2
  • Can you verify that this works on magento 2.1?
    – Mackelito
    Commented Aug 26, 2016 at 14:06
  • @Mackelito The answer works on Magento 2.2
    – Key Shang
    Commented Mar 23, 2018 at 7:39
1

Try using quote_id instead of cartId

Posting this

qty:1
quote_id:"75fc406b9aadbad6fe1b9a2df9881acd"
sku:"24-MB03"

to "V1/guest-carts/75fc406b9aadbad6fe1b9a2df9881acd/items"

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.