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.
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.
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>'); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Send POST request with raw XML body to the API endpoint | Request sent with Content-Type: application/xml and body: <request><data>Test</data></request> | — | PASS |
| 2 | Receive response from server | Response received with status code 200 and body containing <message>Success</message> | — | PASS |
| 3 | Check that response status code is 200 | Response status code is 200 OK | pm.response.to.have.status(200) | PASS |
| 4 | Verify response body contains <message>Success</message> | Response body includes the XML element <message>Success</message> | pm.expect(responseXml).to.include('<message>Success</message>') | PASS |
Raw body option in Postman when testing APIs?application/xml so the server knows to parse XML.application/json is for JSON, text/plain is plain text, and multipart/form-data is for file uploads.<note> <to>Alice</to> <from>Bob</from> <message>Hello</message> </note>
application/xml?application/xml, the server receives the exact XML text including tags.<user> <name>John</name> <age>30</age> </user>
application/xml, the server may reject the request with 400 error.START successfully?START.text/plain to inform the server correctly.Pass the test and this pattern moves unknown