How to validate the contents in the request body

Is there a way to validate the contents in the request body before sending the request.
for example ,

  1. To validate if a particular xml tag appears twice.
  2. To check if a particular xml value is present in xml

Postman version:win64-7.25.0

Hey @sopau, welcome to the community! :wave:

You most certainly can validate data before it’s used in the request being sent.

For this, you would need to add code to the β€œPre-request Script” which is executed before the request is sent!

Postman Sandbox comes bundled with popular Node.js modules that should help you manipulate and use XML data.

checkout Cheerio and xml2js modules which should come useful to handle XML data.

Also, have a look at this post: Working with XML in Postman Scripts , linking to a tutorial-video, which looks to be pretty comprehensive! :+1:

1 Like