Newman doesn't accept environment variable

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.

Hello everyone!

I hoped I didn’t need to create a new topic here, but I think I have to.

{
    "name": "TestDiag",
    "gtin": "{{randomNumber}}",
    "description": "TestDiag",
    "productTypes": [1, 1],
    "diagnostics": [{{envDiag}}]
}

This is the body I send and when I try to send it with Postman, everything works fine. As soon as I use newman and send exactly the same, I get an HTTP415.. can someone help me with that?

Generating the variable is done by:
pm.environment.set("envDiag", "3")

Same if I try with:
pm.environment.set("envDiag", 3)

I’m really hopeless.. need help! :frowning:

Thanks in advance!!

Michael

Ok, I have no idea why, but I changed “pm.environment.set” to “pm.collectionVariables.set” and now it works. Seems like newman had problems getting that variable of the environment file.