0

I try to call the carts/mine GET route of the Magento 2 REST API, but it does not show a request sample in the documentation.

enter image description here

It says "Returns information for the cart for a specified customer."

But how do I specify the customer?

2 Answers 2

1

carts/mine endpoint is returning the cart for current logged in user.

If you need get cart for any user, then you need to use carts/{cartId} endpoint (see https://adobe-commerce.redoc.ly/2.4.6-admin/tag/cartscartId#operation/GetV1CartsCartId)

0

carts/mine endpoint is the Customer API and not Admin API.

To specify the customer you will need Authentication Token of that customer.

  1. get token using endpoint - POST /V1/integration/customer/token

    curl -X POST "https://<host>/rest/default/V1/integration/customer/token" \ -H "Content-Type:application/json" \ -d '{"username":"[email protected]", "password":"customer_password"}'

    Sample Response - asdf3hjklp5iuytre

  2. Use that authentication token when calling carts/mine endpoint

    curl -X GET "https://<host>/rest/default/V1/carts/mine" -H "Authorization: Bearer asdf3hjklp5iuytre"

Checkout this link Token-based authentication more details like token lifetime and related configurations.

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.