API Testing - Postman Collection
Overview
This page provides details on the MG API Postman collection for automation testing. Currently, this extends to testing the downloading of CSV files from dashboards via API. It also includes information on Cypress automated tests that validate this functionality as part of the overnight automation test suite.
Dashboards CSV API Testing on Production
How to Access the API Collection
1. Download the Collection
The Postman collection is available at:
- MG API.postman_collection.json
Import the collection into Postman.
2. Environment Setup
Add the required environment variables (retrieve client_id and client_secret from Account Settings):
client_idclient_secretaccess_token(generated after authentication)refresh_token(optional)
These can be set in the Postman Environment Variables section.
Available API Endpoints
1. Authenticate (Retrieve Access Token)
- Method: POST
- URL:
https://api.methodgrid.com/v1/authenticate - Headers: None
- Body:
client_id: {{client_id}}client_secret: {{client_secret}}- Response:
access_tokenrefresh_token
2. Dashboard Grids
- Method: GET
- URL:
https://api.methodgrid.com/v1/dashboards/grids - Headers:
Authorization: Bearer {{access_token}}
3. Dashboard Elements
- Method: GET
- URL:
https://api.methodgrid.com/v1/dashboards/elements - Headers:
Authorization: Bearer {{access_token}}
4. Dashboard Stage Gates
- Method: GET
- URL:
https://api.methodgrid.com/v1/dashboards/stage-gates - Headers:
Authorization: Bearer {{access_token}}
5. Dashboard Tasks
- Method: GET
- URL:
https://api.methodgrid.com/v1/dashboards/tasks - Headers:
Authorization: Bearer {{access_token}}
Downloading CSV Files via API
To download a CSV file, follow these steps:
- Ensure you are authenticated and have a valid
access_token - Identify the required API endpoint that provides CSV export functionality
- Send a GET request with the Authorization header
- Save the response as a
.csvfile
Cypress Automated Tests
Cypress tests have been created to automate API testing as part of our overnight automation suite. These tests verify the functionality of CSV downloads.
Test Scenarios
- Authentication and token retrieval
- Verification of CSV response structure for:
- Dashboard Grids
- Dashboard Elements
- Dashboard Tasks
- Dashboard Stage Gates
The tests ensure:
- API responses return a 200 status
- CSV headers match expected values
- Authorization tokens are handled correctly