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"
}
}
-
Stop posting same issue continuously , check here magento.stackexchange.com/questions/183465/…Sohel Rana– Sohel Rana2017年07月13日 11:43:04 +00:00Commented Jul 13, 2017 at 11:43
1 Answer 1
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]
-
I'm still getting the same error. I got the token and after that sending request to
/rest/default/V1/carts/mine. Any idea?Bhargav Nanekalva– Bhargav Nanekalva2018年05月31日 06:33:05 +00:00Commented 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 Kasazus– zus2018年10月30日 06:24:00 +00:00Commented Oct 30, 2018 at 6:24