Send POST request with raw XML body and verify response
Preconditions (2)
✅ Expected Result: Response status code is 200 OK and response body contains confirmation message with order id 123
pm.test('Status code is 200', function () { pm.response.to.have.status(200); }); pm.test('Response contains order id 123', function () { const responseBody = pm.response.text(); pm.expect(responseBody).to.include('<id>123</id>'); });
The first test checks that the response status code is exactly 200, which means the request was successful.
The second test reads the response body as text and verifies it contains the XML tag with order id 123, confirming the order was processed.
Using pm.response.to.have.status(200) is the standard way in Postman to assert status codes.
Checking the raw response text for the expected XML snippet ensures the server returned the correct data.
Now add data-driven testing with 3 different XML orders having different ids and items
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