Forum Discussion
POSTMAN multiple pool creation
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.
- Feb 14, 2025
The error message you're seeing indicates that the API expects a single JSON object, but it received an array instead.
To create multiple pools, you need to send each pool creation request individually or use a different approach to handle multiple objects.Correct Approach for Multiple Pool Creation
- Single Request for Each Pool:
- You can send individual POST requests for each pool. This ensures that each request is a valid JSON object.
- Using a Collection Runner in POSTMAN:
- You can use POSTMAN's Collection Runner to iterate over a data file containing multiple pool configurations. This way, each iteration sends a single JSON object.
Example of a Single Pool Creation Request
Here’s how you should format a single pool creation request:
{
"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"}
]
}Using POSTMAN Collection Runner
- Create a Data File:
- Create a JSON or CSV file with your pool configurations. For example, a JSON file (pools.json) might look like this:
{
"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"}
]
}
] - Set Up POSTMAN:
- Create a new POST request in POSTMAN with the URL for pool creation.
- In the Body tab, select raw and JSON.
- Use a variable for the request body, like {{requestBody}}.
- Pre-request Script:
- Add the following script in the Pre-request Script tab to set the request body from the data file:
- Run the Collection:
- Use the Collection Runner to run the collection with the data file (pools.json). POSTMAN will iterate over each entry in the file and send individual requests.
Why the Wrong Options are Incorrect
- Sending an Array Instead of an Object:
- The API expects a single JSON object per request. Sending an array directly causes a parsing error because the API cannot process multiple objects in a single request.
- Incorrect JSON Structure:
- JSON must be properly structured with matching braces and brackets. Any deviation from the correct structure will result in errors, as the API cannot parse the malformed JSON.
- JSON must be properly structured with matching braces and brackets. Any deviation from the correct structure will result in errors, as the API cannot parse the malformed JSON.
By following these steps, you should be able to create multiple pools using POSTMAN without encountering the 400 error.
- Single Request for Each Pool:
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com