Test Overview
This test creates a Postman monitor to run a collection automatically and verifies the monitor creation success message.
This test creates a Postman monitor to run a collection automatically and verifies the monitor creation success message.
import requests # Set Postman API endpoint and API key api_key = 'your_postman_api_key' collection_uid = 'your_collection_uid' url = 'https://api.getpostman.com/monitors' # Define monitor creation payload payload = { "monitor": { "name": "Daily API Test Monitor", "target": { "type": "collection", "data": { "uid": collection_uid } }, "environment": null, "schedule": { "enabled": true, "delay": 0, "interval": { "count": 1, "unit": "hour" } }, "region": "us-east-1" } } # Set headers headers = { 'X-Api-Key': api_key, 'Content-Type': 'application/json' } # Send POST request to create monitor response = requests.post(url, json=payload, headers=headers) # Assert monitor creation success assert response.status_code == 200, f"Expected status 200 but got {response.status_code}" json_response = response.json() assert 'monitor' in json_response, "Response JSON does not contain 'monitor' key" assert json_response['monitor']['name'] == 'Daily API Test Monitor', "Monitor name mismatch"
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Test environment ready with API key and collection UID configured | - | PASS |
| 2 | Sends POST request to Postman API endpoint to create a monitor with specified name and schedule | HTTP POST request sent to https://api.getpostman.com/monitors with JSON payload | - | PASS |
| 3 | Receives HTTP response from Postman API | Response status code and JSON body received | Check response status code is 200 | PASS |
| 4 | Parses JSON response and verifies 'monitor' key exists | JSON response parsed | Verify 'monitor' key is present in response JSON | PASS |
| 5 | Verifies the monitor name in response matches the requested name | Monitor details extracted from response | Monitor name equals 'Daily API Test Monitor' | PASS |
| 6 | Test ends successfully | Monitor created and verified | - | PASS |