I have a situation where I’m sending JSON input payloads to my API that have arrays whose lengths can vary. I am wondering how to best deal with this when using an external file to populating my request body.
I put a couple snippets of example request bodies - but basically, the “components” , “faultCodes” , “sensors” , “measurements” arrays can all be of varying length (all of which are valid inputs).
So if I want to pull these request bodies in from an external file and have postman iterate through them, how do I need to structure the request body in postman to accept the varying JSON coming from the external file?
For example:
Request body 1:
{
“TestId”: “00”,
“comp”: [
{
“comptName”: “5.01”,
“fault”: [
{
“faultKey”: “1X”,
“faultValue”: 1
},
{
“faultKey”: “2X”,
“faultValue”: 2
},
],
“sensors”: [
{
“SerialNumber”: “600607”,
“measurements”: {
“LFrequency”: {
“x”: {
“unit”: “G”
},
“y”: {
“unit”: “G”
},
“z”: {
“unit”: “G”
},
},
}
}
]
}
],
}
Request body 2:
{
“TestId”: “00”,
“comp”: [
{
“compName”: “5.01”,
“fault”: [
{
“faultKey”: “1X”,
“faultValue”: 1
},
{
“faultKey”: “2X”,
“faultValue”: 2
},
{
“faultKey”: “3X”,
“faultValue”: 3
},
],
“sensors”: [
{
“SerialNumber”: “607”,
“measurements”: {
“LowFrequency”: {
“x”: {
“unit”: “G”
},
“y”: {
“unit”: “G”
},
“z”: {
“unit”: “G”
},
},
}
}
{
“SerialNumber”: “600608”,
“measurements”: {
“LowFrequency”: {
“x”: {
“unit”: “G”
},
“y”: {
“unit”: “G”
},
“z”: {
“unit”: “G”
},
},
}
}
]
}
{
“compName”: “5.02”,
“fault”: [
{
“faultKey”: “1X”,
“faultValue”: 1
},
{
“faultKey”: “2X”,
“faultValue”: 2
},
],
“sensors”: [
{
“SerialNumber”: “600609”,
“measurements”: {
“LowFrequency”: {
“x”: {
“unit”: “G”
},
“y”: {
“unit”: “G”
},
“z”: {
“unit”: “G”
},
},
}
}
]
}
],
}