How to test Magento2 REST API with Postman

This assumes you've created a new Integration in Magento 2 by going to M2 Dashboard -> System -> Integrations. Create a new one, give it Resource Access to ALL and save. Then Authorise it, then it'll create new consumer_key,consumer_secret,access_token,token_secret values for you.

Afterwards :

1. Create account /  login on Postman.com

2. Create a new Environment - name it "API Magento"
Set up environment variables for :
"magento_api_url" : https://website.com/index.php/rest
"admin_username" : admin user
"admin_password". : admin password

3. Next create a new POST request to obtain a new admin token - - Set Environment to "API Magento" (so it can read the vars)
URL : {{magento_api_url}}/all/V1/integration/admin/token?username={{admin_username}}&password={{admin_password}}

params should be:
username : {{admin_username}}
password : {{admin_password}}

Click Send and it should return a token value - you'll need to paste this into the headers in the next step.

4. Create a new GET request for the REST API call

URL : {{magento_api_url}}/V1/products/PRODUCT_SKU

Headers tab:
Content-Type : application/json
Authorization : Bearer <TOKEN FROM ABOVE>

Authorization tab:
Type : "OAuth 1.0"
set "Add authorization to" : Request headers

Fill in consumer_key,consumer_secret,access_token,token_secret etc. using values from your Magento 2 integration set-up.

Click "Send" and you should get the REST API response with product details in JSON format.

JR August 2021

Helpful links:
Amasty Postman Magento2 Guide

Leave a Reply