0
0
Postmantesting~10 mins

Raw body (text, XML) in Postman - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test sends a POST request with a raw XML body to an API endpoint and verifies that the response status is 200 and the response body contains the expected XML element.

Test Code - Postman
Postman
pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});

pm.test("Response contains expected XML element", function () {
    const responseXml = pm.response.text();
    pm.expect(responseXml).to.include('<message>Success</message>');
});
Execution Trace - 4 Steps
StepActionSystem StateAssertionResult
1Send POST request with raw XML body to the API endpointRequest sent with Content-Type: application/xml and body: <request><data>Test</data></request>-PASS
2Receive response from serverResponse received with status code 200 and body containing <message>Success</message>-PASS
3Check that response status code is 200Response status code is 200 OKpm.response.to.have.status(200)PASS
4Verify response body contains <message>Success</message>Response body includes the XML element <message>Success</message>pm.expect(responseXml).to.include('<message>Success</message>')PASS
Failure Scenario
Failing Condition: Response status code is not 200 or response body does not contain the expected XML element
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify first after sending the POST request?
AThat the response body is empty
BThat the response status code is 200
CThat the request body is XML
DThat the request headers are correct
Key Result
Always verify both the response status code and the response body content when testing APIs with raw XML bodies to ensure the server processes requests correctly.