Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 
Custom Alert Banner

POSTMAN multiple pool creation

Chause1
Cirrus
Cirrus

Good day,

We are looking at using POSTMAN to "script" pool creations.

I am able to submit one pool at a time to the device but when I attempt multiple pools it fails with a 400 error.

"code"400,
    "message""Found invalid JSON body in the request.",

Sample:

{
    "name":"x10779",
    "partition":"x",
    "loadBalancingMode":"least-connections-node",
    "monitor":"/Common/tcp",
    "members":[
         {"name":"x.x.x.x:10779"}
    ]
}
 
 {
 "name":"x10778",
    "partition":"x",
    "loadBalancingMode":"least-connections-node",
    "monitor":"/Common/tcp",
    "members":[
         {"name":"x.x.x.x:10778"}
    ]
}
5 REPLIES 5

mihaic
MVP
MVP

those are 2 json objects.

It should be one so you need to put those 2 in a list of dictionaries, something like this:

 
[ 
{
"name":"x10779",
"partition":"x",
"loadBalancingMode":"least-connections-node",
"monitor":"/Common/tcp",
"members":[
{"name":"x.x.x.x:10779"}
]
}
,
{
"name":"x10778",
"partition":"x",
"loadBalancingMode":"least-connections-node",
"monitor":"/Common/tcp",
"members":[
{"name":"x.x.x.x:10778"}
]
}
]
 

Hi

Thanks for the feedback, however still no luck.

{
    "code"400,
    "message""Found invalid JSON body in the request. The expected JSON type is object. The received JSON type is array.",
    "errorStack": [],
    "apiError"1
}

 

"name":"y_PROD",
"partition":"y"
"loadBalancingMode":"least-connections-node"
"monitor":"/Common/tcp"
    "members":[
         {"name":"x.x.x.x:11"},
         {"name":"x.x.x.x:11"}
    ]
}
,
{
"name":"x_PROD",
"partition":"y
"loadBalancingMode":"least-connections-node"
"monitor":"/Common/tcp"
    "members":[
         {"name":"x.x.x.x:10"},
         {"name":"x.x.x.x:10"}
    ]
}
]

mihaic
MVP
MVP

Probably you need an API request for each pool you create.

mihaic
MVP
MVP

I don't know about Postman but it would be easier to use python or Ansible for this.

There is a way to add a data file  ( where  you have a list of json dictionaries) to Postman and get data  from it but it did not work for me for some reason. 

mihaic
MVP
MVP

I've managed to create pools via Postman. You will need to a collection and under it the post request.

Then you need a file containing your configuration of the pools, under your user ~/Postman/files/ folder.

here is an example of a file:

[

    {

        "name": "pool1",

        "loadBalancingMode": "least-connections-node",

        "monitor": "/Common/tcp",

        "members": [

            {

                "name": "8.8.8.8:10779"

               

            } ,

            {  

                "name": "1.1.1.1:80"

            }

        ]

    },

    {

        "name": "pool2",

        "loadBalancingMode": "round-robin",

        "monitor": "/Common/tcp",

        "members": [

            {

                "name": "9.9.9.9:10779"

            },

            {

                "name": "2.2.2.2:443"

            }

        ]

    }

]  

You also need to put this under the  Pre-request Script:

pm.variables.set(`requestBody`JSON.stringify(pm.iterationData.toObject()))

Under the body, select raw and JSON type and put this:

{{requestBody}}

Then you have to run the Collection and select the above file.

And that's it.

I've also created a collection for creating a VIP.