# Newman doesn't accept environment variable

**URL:** <https://community.postman.com/t/newman-doesnt-accept-environment-variable/19383>\
**Category:** Help Hub\
**Tags:** newman-project\
**Created:** [January 21, 2021, 12:16pm UTC](https://community.postman.com/t/newman-doesnt-accept-environment-variable/19383 "2021-01-21T12:16:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![maintenance-astronom](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@maintenance-astronom](https://community.postman.com/u/maintenance-astronom)\
**Post date:** [January 21, 2021, 12:16pm UTC](https://community.postman.com/t/newman-doesnt-accept-environment-variable/19383/1 "2021-01-21T12:16:45Z")

</div>

> **Archived topic — this may be out of date.**  
> Newman has been replaced by the **[Postman CLI](https://learning.postman.com/docs/postman-cli/postman-cli-overview/)**, 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](https://github.com/postmanlabs/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](https://learning.postman.com/docs/), try the free [Postman tools](https://www.postman.com/tools) (no account needed), or join us on [Discord](https://discord.gg/58aNNsRBGR).

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! ☹

Thanks in advance!!

Michael

---

<div class="post-metadata">

**Author:** ![maintenance-astronom](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@maintenance-astronom](https://community.postman.com/u/maintenance-astronom)\
**Post date:** [January 21, 2021, 12:30pm UTC](https://community.postman.com/t/newman-doesnt-accept-environment-variable/19383/2 "2021-01-21T12:30:18Z")

</div>

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.
