0
0
Postmantesting~8 mins

Raw body (text, XML) in Postman - Framework Patterns

Choose your learning style9 modes available
Framework Mode - Raw body (text, XML)
Folder Structure
postman-project/
├── collections/
│   └── api-requests.postman_collection.json  
├── environments/
│   ├── dev.postman_environment.json
│   ├── staging.postman_environment.json
│   └── prod.postman_environment.json
├── tests/
│   └── raw-body-tests.postman_collection.json
├── scripts/
│   └── pre-request-scripts.js
├── data/
│   └── test-data.json
└── README.md
    

This structure organizes Postman collections, environment files, test scripts, and test data separately for clarity and maintainability.

Test Framework Layers
  • Collections Layer: Contains API requests with raw body payloads (text, XML) defined in the request body tab.
  • Environment Layer: Holds environment variables like base URLs, credentials, and tokens for different deployment stages.
  • Scripts Layer: Includes pre-request and test scripts to set variables, validate responses, and handle dynamic data.
  • Data Layer: External JSON files for data-driven testing, feeding different raw body inputs into requests.
  • Tests Layer: Collections dedicated to automated tests verifying API behavior with raw body inputs.
Configuration Patterns

Use environment files to manage configuration:

  • Environments: Separate JSON files for dev, staging, and prod with variables like base_url, auth_token.
  • Raw Body Templates: Store raw XML or text payloads directly in the request body or as environment/global variables for reuse.
  • Dynamic Variables: Use Postman scripts to insert dynamic values into raw bodies before sending requests.
  • Secure Credentials: Keep sensitive data in environment variables, not hardcoded in raw bodies.
Test Reporting and CI/CD Integration
  • Run Postman collections via newman CLI tool to automate tests in CI/CD pipelines.
  • Generate HTML or JSON reports from newman runs to visualize pass/fail results.
  • Integrate with Jenkins, GitHub Actions, or GitLab CI to trigger tests on code changes.
  • Use environment variables in CI to switch between test environments automatically.
Best Practices
  • Keep raw body payloads readable and well-formatted (indent XML properly).
  • Use variables inside raw bodies to avoid duplication and ease maintenance.
  • Validate response content type and body structure in test scripts to ensure correct API behavior.
  • Separate environment-specific data from raw body content to keep tests portable.
  • Use data-driven testing by feeding multiple raw body inputs from external JSON files.
Self Check

Where in this folder structure would you add a new raw XML payload template to reuse in multiple requests?

Key Result
Organize Postman projects with clear separation of collections, environments, scripts, and data to manage raw body (text, XML) API tests effectively.