Data already exists on the device I am trying to write to

Disclaimer: I am a network engineer and am very new to JSON, APIs and any sort of programming. I’ve been able to utilize postman to great success thus far but I am hitting a brick wall.

Here’s an outline with best practices for making your inquiry.

My question: Is there a way to write data that is unique and skip over data that already exists in the destination?

Details (like screenshots):
So I am running a POST request that adds an array of IP addresses and fqdns to our corporate firewalls. I keep getting this error because the device in question already has a lot of the IPs and FQDNs added to it, its just missing a few key ones. It is totally out of the question to delete the current exceptions (one going forward that just isn’t scalable) and this is a core location that our entire network depends on.

Some additional details: I’ve noticed that it always stops at the first set of data (as I said most of the data is already in place, its missing just a few items).

My question: Is it possible to skip, move past or ignore the already duplicate data in the POST request so that the unique data gets written??

“status”: {
“success”: false,
“cli”: {
“mode”: “config_mode”,
“depth”: 1,
“command”: “address-object fqdn”,
“configuring”: true,
“pending_config”: false,
“restart_required”: “FALSE”
“info”: [
“level”: “error”,
“code”: “E_EXISTS”,
“message”: “Already exists.”

Example snippet of the array:

“address_objects”: [
“fqdn”: {
“name”: “”,
“domain”: “”,
“zone”: “WAN”,
“dns_ttl”: 0

  • this continues on but there are hundreds of objects in the array.

I’ve already tried: Not much, like I said I am new to all this :slight_smile:

Thanks in advance for all your help!

It’s the API on the firewall that is controlling the response, so the short answer is no.

If the API requires all of the data to be unique and for you to not send duplicate entries, then that is what you need to do.

What might be possible though is for you to retrieve the current entries first using a GET request and save those to a collection\environment variable.

Then utilise a pre-request script in the POST request to compare the two lists and remove any duplicates.

Postman uses JavaScript under the hood for scripting and this will require some JavaScript knowledge as you will need to loop through one of the lists to compare to the second. At a minimum you need to understand arrays, loop and the filter\find functions.

It’s unlikely anyone here will write that code for you. However, if you run into issues, feel free to post what you’ve tried and someone here will be more inclined to help.

Another option is to separate your address_objects into individual arrays with a single element, and use setNextRequest to loop through the address objects one at a time, this way if one fails the others will still run. This is also an advanced feature that will require coding. So you’ll still have to learn JavaScript.

The final alternative (and would be my preference) is to not script this and clean your data before you try and import it. Pull the current data and compare it to the data set you want to import in a spreadsheet.

1 Like