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.
It says "Returns information for the cart for a specified customer."
But how do I specify the customer?
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.
It says "Returns information for the cart for a specified customer."
But how do I specify the customer?
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)
carts/mine endpoint is the Customer API and not Admin API.
To specify the customer you will need Authentication Token of that customer.
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
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.