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.
I’m a beginner and trying to run postman collection in Newman using linux system. I have created collection with Post login request under Folder1, stopping the ldap server on and trying to add,update,delete user requests under Folder 2 to get “server down message” status 400
The issue is with the FOlder 2 . From Postman, I get a 200 OK by disabling cookie jar, and from Newman, the same request returns 401 Unauthorized not 400.
Even though i added header cookie value on Folder2 requests after stopping the server.
This is how the authorization works for this API:
2 set-cookies values are obtained from the login request, specifically from the response headers, where we have 2 Set-Cookie headers with the corresponding values for the cookies.
How I’m obtaining the values and using them
In the request 1 (login) (Folder1) I have the following code in the Test tab:
// Save cookies from response headers to use it in subsequent requests
const cookies = pm.response.headers.all().filter(headerObj => headerObj.key === ‘Set-Cookie’).map(headerObj => headerObj.value.split(‘;’)[0]);
pm.environment.set(‘cookies’, cookies.join('; '));
If I print the saved values I obtain something like this:
Bearer=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJkYjZlN2QzMy04OGI4LTQ3OTQtODliYy01Y2E3ZWE0ZGJlZTkiLCJleHAiOjE2Nzk5MjI2NTcsImZyZXNoIjp0cnVlLCJpYXQiOjE2Nzk5MjE3NTcsInR5cGUiOiJhY2Nlc3MiLCJuYmYiOjE2Nzk5MjE3NTcsImlkZW50aXR5Ijp7InVzZXJuYW1lIjoiYWRtaW4iLCJyb2xlIjoic3VwZXJ1c2VycyIsInJqdGkiOiI3YWY3ZmZjZi0yOGI1LTQ0YjQtOTFhYS1hMGEyODliYzRlYjMifX0.bJ5db8W5orFIWqTBUygZA8mK2y6AjFs7N8dvax_LZVY; Refresh=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3YWY3ZmZjZi0yOGI1LTQ0YjQtOTFhYS1hMGEyODliYzRlYjMiLCJleHAiOjE2ODI1MTM3NTcsImlhdCI6MTY3OTkyMTc1NywidHlwZSI6InJlZnJlc2giLCJuYmYiOjE2Nzk5MjE3NTcsImlkZW50aXR5Ijp7InVzZXJuYW1lIjoiYWRtaW4iLCJzZXNzaW9uVGltZW91dCI6MTUsInJvbGUiOiJzdXBlcnVzZXJzIn19.S5f0A6HC9XNe4xMo6ODKLzYyXLOoUGsDqz8sguH-10o
In the request 2 (Folder2) (Edit users) I do the following in the pre-request tab:
pm.request.headers.add({
key: “Cookie”,
value: pm.environment.get(“cookies”)
});
Note: Also tried inserting the varaibles directly in headers ex: Cookie: {{cookies}} but with the same result.
So, if I run this from Postman, this second request respond 200 and the item is created (expected response).
When running it from Newman I get 401. Please help
Here is the new man shell script which i am running , both the folders are under “ldap-down.postman_collection.json”
newman run ldap-down.postman_collection.json -e L1-70.postman_environment.json --folder folder1 -r htmlextra -k
systemctl stop slapd
newman run ldap-down.postman_collection.json -e L1-70.postman_environment.json --folder folder2 -r htmlextra -k
systemctl start slapd