0

enter image description hereI am working on an API where I need all product of Magento store. I am using postman to make a collection, but I am getting this error. kindly tell me what is causing this errorenter image description here

image with the enter image description herenew error

1

When you look at webapi.xml you could see route of above mentioned api defined like this:

<route url="/V1/products" method="GET">
        <service class="Magento\Catalog\Api\ProductRepositoryInterface" method="save"/>
        <resources>
            <resource ref="Magento_Catalog::products" />
        </resources>
    </route>

ref="Magento_Catalog::products" means that only users with configured ACL which allow access to this resource are allowed to get it. In magento ONLY admin user can have a configuration of ACL.

So that you will have to use admin token or Integration token

Get an admin token :

   Method:POST Endpoint: /V1/integration/admin/token

For More details refer this official documentation : https://devdocs.magento.com/guides/v2.3/get-started/authentication/gs-authentication-token.html

|improve this answer|||||
  • now it shows message": "\"%fieldName\" is required. Enter and try again. – Adarsh Shukla Feb 18 '19 at 9:48
  • i am adding screen shot – Adarsh Shukla Feb 18 '19 at 9:49
  • i got admin token but not product data – Adarsh Shukla Feb 18 '19 at 9:51
  • baseURL is in a variable {{baseurl}} – Adarsh Shukla Feb 18 '19 at 9:53
  • ok got it. you will have to mention the searchcriteria – NID Feb 18 '19 at 9:53
0

You need to pass Admin token in Headers. Below is docs to get Admin token in Maganto 2.

https://devdocs.magento.com/guides/v2.3/rest/tutorials/orders/order-admin-token.html

|improve this answer|||||
0
baseurl/rest/default/V1/products?searchCriteria[currentPage]=4&searchCriteria[pageSize]=10

Use above endpoint to eradicate the issue fieldName is a required field

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.