Magento 2 | Test API with POSTMAN

Intro:

For a customer request, i need to instal a module that able admin add extra fields to customer account and in checkout area.
That isn’t a problem, we used a commercial module that made the job.
The real problem is another, the customer need to dialog between magento and a business management software, and that happend by using Magento’s REST API.
I need to test if all custom fields are regulary exposed by the API.

First phase : Authentication

For test the API, i use POSTMAN, Postman is the only complete API development environment, you can download it for free here.

Now that you had downloaded and installed POSTMAN, we can try to dialogate with our Magento API.

First of all must have user and password of Magento Repository.
For bring them, login in Magento Marketplace, Click your account name in the top-right of the page and select My Profile, click Access Keys in the Marketplace tab.

Click Create a New Access Key. Enter a specific name for the keys and click OK.
Use the Public key as your username and the Private key as your password.

Now we can call our first root, insert in the url input the url below and as method select “POST”:

http://yourdomain.com/rest/V1/integration/admin/token?username=developer.beprime&password=)K!mMcq2rVW (autenticazione) ( no-auth )
From this call Magento answer wit a token, es: “e18te890ntzj0eww19mglsvhsremyny4”.

You must copy and paste this token in “Authorization” tab, by selecting in select box (TYPE) on left “Bearer Token”.

Now in the url input insert https://yourdomain.com/rest/V1/customers/1954
(last parameter is the user id for witch you want have API, you find it in Magento Admin under “customers” menu ), and as method select “GET”

Ince Magento answer with the customer json, you can download it ( by click on “download” button ), or you can save the call for future quick access ( button “save” ).

For show all Magento root: https://yourdomain.com/swagger

In the same way as we made before, we can test all Magento API.

That’s all have fun !!