Archived topic — this may be out of date.
Newman has been replaced by the Postman CLI, Postman’s official, signed command-line tool. It runs collections as Newman did, and also lints API specs, runs mocks and monitors, and syncs local files with Postman from your terminal, CI/CD pipeline or coding agent.
Working with an AI coding agent? The Postman plugin lets agents in Claude Code, Cursor, Codex and others design, mock, test and ship APIs with Postman.
For current help, see the Postman docs, try the free Postman tools (no account needed), or join us on Discord.
Hi there,
Context
I have a list of files (in order of 100s) where each file contains a request body in the form of a list of hashmaps. If I copy-paste the files individually into postman, everything seems to be working well so I’m trying to automate running each of these files to a specific endpoint in my collection using newman.
For that purpose, I decided to write a simple batch script that would iterate over the files in my directory and pass each file to newman run. My batch script is as follows:
@echo off
set JSON_DIR=<EXACT-DIR-LOCATION>
for %%f in (%JSON_DIR%\*.json) do (
rem add --verbose to get more info out of each call.
echo %%f
newman run <COLLECTION_NAME>.json -d "%%f" ^
--folder "<REQUEST_NAME>" ^
--iteration-count 1 ^
--verbose
)
I’m also adding the data snippet from one of the files:
[
{
"id": null,
"geohash": null,
"latitude": 19.26362,
"sequence": 0,
"longitude": 73.07356,
"googleAddress": null
},
{
"id": null,
"geohash": null,
"latitude": 19.26045,
"sequence": 1,
"longitude": 73.06872,
"googleAddress": null
},
{
"id": null,
"geohash": null,
"latitude": 19.25907,
"sequence": 2,
"longitude": 73.06629,
"googleAddress": null
}
]
My POST endpoint is designed to take in a list of such hashmaps and push the data onto a graph database.
Solutions I’ve tried
-
Keeping the Request Body empty in postman, before exporting it:
Naturally, I assumed that if I only pass the data file via-dit will automatically add it as the request body (as if it was copy-pasted). But my fastapi service gave the following error:
Exception has occurred: RequestValidationError [{'type': 'missing', 'loc': ('body',), 'msg': 'Field required', 'input': None, 'url': 'https://errors.pydantic.dev/2.5/v/missing'}]denoting that it may not be working as I expected (either because the values are not getting parsed or passed). -
Adding variables in the expected format, before exporting it:
My request body in Postman looked like the following:
[
{
"id": null,
"latitude": {{latitude}},
"sequence": {{sequence}},
"longitude": {{longitude}},
"googleAddress": null,
"geohash": null
}
]
Doing this leads to newman only taking the first element of the list and passing it to the fastapi service, I can confirm this because if I increase the length to two such hashmaps, I get two elements in the request at the endpoint.
Question
- If I have multiple files and each file contains variable number of such element in the form of a list, how do I pass all of it to an endpoint as a single request body?
- How do I pass variables optionally null variables (like
id,geohash,googleAddress)? If I pass it as variable, I get a validation error in case the value is is explicitly null in the file.
