2

In postman , I tried to add the product to the cart for registered user using this API :

/rest/V1/carts/mine

but I am facing an error like

{
    "message": "Consumer is not authorized to access %resources",
    "parameters": {
        "resources": "self"
    }
}
1

1 Answer 1

2

Follow the below steps by replacing your domain URL and use your customer credentials to login and do the add to cart.

Step 1:-

Get the registered user login details(from website) so that you will get authentication key hence follow the below step first

note:- please note down the response token/key it will useful for next following steps at header section

Method:- POST

API:- http://yoursite.com/rest/V1/integration/customer/[email protected]&password=test@123

screenshot:- [Customer Authentication with Magento through Postman]

Step 2:-

Create Cart using below API call along with the adding header section keys and values as shown below and it will generate cart id.

Method:- POST

API:- http://yoursite.com/rest/V1/carts/mine

screenshot:- [Create new cart in Magento through Postman]

Step 3:- Add item to Cart

Method:- POST

API:- http://yoursite.com/rest/V1/carts/mine/items

Body section: { "cart_item": { "quote_id": "15", "sku": "24-MB03", "qty": 1 } }

screenshot:- [Add a item to cart in Magento through Postman]

Note:- don't forget to add authentication key and value & Content-Type is application/JSON in the postman app at header section. Based on product type this input has to vary.

Step 4:-

Get Cart details with cart items

Method:- GET

API:- http://yoursite.com/rest/V1/carts/mine

screenshot:- [get Cart details/items from Magento through Postman]

2
  • I'm still getting the same error. I got the token and after that sending request to /rest/default/V1/carts/mine. Any idea? May 31, 2018 at 6:33
  • magento ver 1.9.2.3,I am work with REST API in POSTMAN, i have all oAuth 1.0 details like Consumer Key,Consumer Secret,Access Token,Token Secret. Now i moved to oAuth 2.0, how can i get my all oAuth 2.0 details? @Nagaraju Kasa
    – zus
    Oct 30, 2018 at 6:24

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.