Magento 2 – Authorization Failed During Category Creation Using REST API

aclapimagento2oauthrest

I am playing with magento 2 Rest API to add category in magento admin. I am writing below code, but showing "401 Unauthorized" and showing message

Consumer is not authorized to access %resources

Magento_Catalog::categories

I am using below code to add category in magento console, can anyone help me on this? Thanks in advance.

POST Method: [MAGENTO URL]/index.php/rest/V1/categories/

Request Body:
{
"id": 0,
"parentId": 0,
"name": "test category",
"isActive": true,
"position": 0,
"level": 0,
"includeInMenu": true,
"extensionAttributes": {},
}

but not working. any solution?

Thanks

Rahul Anand.

Best Answer

Follow the steps defined in authentication guide provided by Magento.

http://devdocs.magento.com/guides/v2.0/get-started/authentication/gs-authentication.html

This guide is more elaborated and helpful in achieving your requirements. Magento team has added more details in it and it will help you out in authenticating your request.

You can use any method:
- Token based
- Oauth based
- Session based

Related Topic