Hi everybody,
I’m quite new with POSTMAN so sorry if the question can be a little “neif” but i’ve this problem and i don’t know how to fix it.
Basically i’m using .csv files to collect variables that then will be used by postman POSTs to populate {{…}} items inside the JSON payload.
Depending on the value of csv fields, i can have or not piece of JSON code included in the post.
Just with an example:
Let’s suppose to have the csv done like this one:
VRF_NAME,BD_NAME,BD_NAME_ALIAS,IP_ANYCAST,L3OUT_ASSOCIATION
IRIDEOS_VRF,IRIDEOS_BD1,IRIDEOS_BD1_ALIAS, ,IRIDEOS_L3OUT
IRIDEOS_VRF,IRIDEOS_BD2,IRIDEOS_BD2_ALIAS,10.2.1.1/24,
IRIDEOS_VRF,IRIDEOS_BD3,IRIDEOS_BD3_ALIAS,10.3.1.1/24,IRIDEOS_L3OUT
As you can see, in the 2nd line is missing the value for the “IP_ANYCAST” variable and in the 3rd line is missing the value for the “L3OUT_ASSOCIATION” variable.
Now, the POST call in JSON is like this one:
{
“fvBD”: {
“attributes”: {
“dn”: “uni/tn-{{TENANT_NAME}}/BD-{{BD_NAME}}”,
“mac”: “00:22:BD:F8:19:FF”,
“arpFlood”: “true”,
“name”: “{{BD_NAME}}”,
“nameAlias”: “{{BD_NAME_ALIAS}}”,
“rn”: “BD-{{BD_NAME}}”,
“unicastRoute”: “true”,
“unkMacUcastAct”: “flood”,
“status”: “created”
},
“children”: [
{
“fvSubnet”: {
“attributes”: {
“dn”: “uni/tn-{{TENANT_NAME}}/BD-{{BD_NAME}}/subnet-[{{IP_ANYCAST}}]”,
“ctrl”: “”,
“ip”: “{{IP_ANYCAST}}”,
“rn”: “subnet-[{{IP_ANYCAST}}]”,
“status”: “created”
},
“children”:
}
},
{
“fvRsCtx”: {
“attributes”: {
“tnFvCtxName”: “{{VRF_NAME}}”,
“status”: “created,modified”
},
“children”:
}
},
{
“fvRsBDToOut”: {
“attributes”: {
“tnL3extOutName”: “{{L3OUT_ASSOCIATION}}”,
“status”: “created”
},
“children”:
}
}
]
}
}
Want i wont to get as outcome is:
- Not include the portion below for the line where “IP_ANYCAST” is empty (or null)
{
“fvSubnet”: {
“attributes”: {
“dn”: “uni/tn-{{TENANT_NAME}}/BD-{{BD_NAME}}/subnet-[{{IP_ANYCAST}}]”,
“ctrl”: “”,
“ip”: “{{IP_ANYCAST}}”,
“rn”: “subnet-[{{IP_ANYCAST}}]”,
“status”: “created”
},
“children”:
}
}
- not include the portion below for the line where “L3OUT_ASSOCIATION” is empty (or null)
{
“fvRsBDToOut”: {
“attributes”: {
“tnL3extOutName”: “{{L3OUT_ASSOCIATION}}”,
“status”: “created”
},
“children”:
}
}
So in summary, i need to make the JSON payload dynamically dependent on some variables. How can i get that?
I really appreciate your feedback.
Thanks
Mario