I have a partner who owns a warehouse with thousands of products. We want to connect our Magento 2.4.5 store to this partner so that we can sell their products using our Magento 2 store. The partner provided us with API token and url. We need to update the product inventory e.g. every 2 days
We have so far tried the following but encountering challenges.
1- Created system/integration in Magento 2 admin. Used an email and password. Assigned all resources but using custom selection. Copied and saved bearer token.
2- Using postman GET- as per attached I entered the url provided by partner to fetch products from partner warehouse. I selected bearer token option and entered the bearer token supplied by partner. I am able to extract all their products in their thousandsenter image description here
3- Method 1 using postman POST – as per attached I entered our M2 api url using rest/V1/products. I entered bearer token generated in step 1. I then get “Internal error. Details are available in Magento log file. Report ID: webapi-66914793a534d”. when I check system.log I see main.CRITICAL: LogicException: Property “0” does not have accessor
method “get0” in class “MagentoCatalogApiDataProductInterface
4- Method 2 using postman POST – as per attached I entered our M2 rest/V1/integration/admin/token to get admin token. I then entered our M2 api url using rest/V1/products. I used the admin bearer token. I then ger error
“message”: “The consumer isn’t authorized to access %resources.”,
“parameters”: {
“resources”: “Magento_Catalog::products”
5- Method using guzzle – installed guzzle using compose composer require guzzlehttp/guzzle. Followed instruction on https://devhooks.in/blog/how-to-perform-3rd-party-api-operations-in-your-magento-using-guzzlehttp. I got lost as I am nost sure where to put this guzzle file and how to invoke it. The same applies to https://developer.adobe.com/commerce/php/tutorials/backend/create-api-integration/ as I have no idea where to place the file and how to invoke it.
6- I followed Mageplaza guide https://www.mageplaza.com/devdocs/magento-2-create-api/ to create a custom api module but got lost how to use it to fetch the products and place them in their appropriate M2 categories
7- I explored curl scripts from w3schools but my confusion is same as with using guzzle
Has anyone got experience with this that they can guide me to a working solution?
Paul Keta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.