Skip empty XML tags if variables from data file are empty


Just started using Postman and really enjoying its ease of use so far. I’m using it to run a collection that configures a Sophos XG firewall via its API.

One issue I have is when creating a “Service” object it could have one or multiple protocols and/or ports defined but if I have empty variables in my data file say because one service has one protocol but another has two then the one with blank values will cause the iteration to fail.

Here is an XML example I’m testing with:


Here is an example data file:

servicename servicetype protocol1 protocol2 sourceport1 sourceport2 destinationport1 destinationport2
Example1 TCPorUDP TCP 1:65535 80
Example2 TCPorUDP TCP UDP 1:65535 1:65535 81 81

This fails example1 because protocol2, sourceport2, and destinationport2 are empty and they are mandatory, but I need them because example 2 has multiple values. So i’m thinking if I could instruct Postman to skip the XML tags of empty values so that each iteration is specific to whether its values are filled in or not then it should work.

I assume this is a relatively common thing to do but wasn’t able to find much in my searches of other posts. Although that said I am new to Postman and the use of API’s in general so may have simply not understood what I was looking at.

Hopefully I’ve explained this ok but happy to provide more information as needed. Can anyone help?

Thanks !