Skip to content

Instantly share code, notes, and snippets.

@jonico
Created December 1, 2025 12:47
Show Gist options
  • Select an option

  • Save jonico/a4b23b7c3f5724f809f1e16d0000d2c2 to your computer and use it in GitHub Desktop.

Select an option

Save jonico/a4b23b7c3f5724f809f1e16d0000d2c2 to your computer and use it in GitHub Desktop.
Include Payload / Response in Postman Tests
#!/bin/bash
# Script to run Postman collection with better response data
# This generates multiple report formats with full response bodies
COLLECTION_ID="24483733-cefed589-9c3d-4dd5-9673-0e913981403e"
ENVIRONMENT_ID="41094746-f8fd4ac6-fb62-4774-b8a5-38c42fd476e3"
TIMESTAMP=$(date +%Y-%m-%d-%H-%M-%S)
REPORT_DIR="postman-cli-reports"
echo "Running LED Name Badge API collection with better response data..."
# Create reports directory if it doesn't exist
mkdir -p "$REPORT_DIR"
echo "πŸ₯‡ 1. JSON Reporter with Newman schema (BEST - response bodies as strings):"
echo "=========================================================================="
postman collection run "$COLLECTION_ID" \
-e "$ENVIRONMENT_ID" \
-r json \
--reporter-json-export "$REPORT_DIR/LED-API-newman-schema-$TIMESTAMP.json" \
--reporter-json-structure newman
echo "βœ… Newman schema JSON saved to: $REPORT_DIR/LED-API-newman-schema-$TIMESTAMP.json"
echo ""
echo "πŸ₯ˆ 2. CLI Reporter with verbose output (shows response bodies in terminal):"
echo "=========================================================================="
postman collection run "$COLLECTION_ID" \
-e "$ENVIRONMENT_ID" \
-r cli \
--verbose
echo ""
echo "πŸ₯‰ 3. HTML Reporter (human-readable format):"
echo "============================================"
postman collection run "$COLLECTION_ID" \
-e "$ENVIRONMENT_ID" \
-r html \
--reporter-html-export "$REPORT_DIR/LED-API-readable-$TIMESTAMP.html"
echo "βœ… HTML report saved to: $REPORT_DIR/LED-API-readable-$TIMESTAMP.html"
echo ""
echo "πŸ“‹ Summary:"
echo "==========="
echo "πŸ₯‡ #1 RECOMMENDED: --reporter-json-structure newman"
echo " β†’ Response bodies as readable JSON strings instead of Buffer arrays"
echo " β†’ Perfect for programmatic processing and automation"
echo ""
echo "πŸ₯ˆ #2 For immediate feedback: -r cli --verbose"
echo " β†’ See response bodies directly in terminal output"
echo " β†’ Great for debugging and quick testing"
echo ""
echo "πŸ₯‰ #3 For sharing/documentation: -r html"
echo " β†’ Beautiful formatted reports for humans"
echo " β†’ Best for stakeholder communication"
echo ""
echo "⚠️ Default Postman CLI JSON creates Buffer arrays - always use Newman schema!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment