# How I can rewrite collection value via Newman

**URL:** <https://community.postman.com/t/how-i-can-rewrite-collection-value-via-newman/17828>\
**Category:** Help Hub\
**Tags:** newman-project, variables, collections\
**Created:** [November 18, 2020, 2:10pm UTC](https://community.postman.com/t/how-i-can-rewrite-collection-value-via-newman/17828 "2020-11-18T14:10:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![drunyak](https://avatars.discourse-cdn.com/v4/letter/d/ba8739/32.png) [@drunyak](https://community.postman.com/u/drunyak)\
**Post date:** [November 18, 2020, 2:10pm UTC](https://community.postman.com/t/how-i-can-rewrite-collection-value-via-newman/17828/1 "2020-11-18T14:10:19Z")

</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. How I can rewrite the value of COLLECTION variable via Newman? I have a request:

```auto
let update_ver = "true";
body = pm.collectionVariables.get('variableVersion');
let expectedBody = body;
pm.test("tryupdatevariable"+ expectedBody, function () {
     if(update_ver == "true" )
    {
        pm.collectionVariables.set('variableVersion', responseBody);
        expectedBody = responseBody;
    }
}); 

```

When I export JSON collection and delete the value of tryupdatevariable then running newman, newman doesn’t set value

---

<div class="post-metadata">

**Author:** ![allenheltondev](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/allenheltondev/32/31738_2.png) [@allenheltondev](https://community.postman.com/u/allenheltondev)\
**Post date:** [November 18, 2020, 2:52pm UTC](https://community.postman.com/t/how-i-can-rewrite-collection-value-via-newman/17828/2 "2020-11-18T14:52:07Z")

</div>

What you’re looking for is persisting variables after the collection run.

According to [this GitHub issue](https://github.com/postmanlabs/newman/issues/831), it looks like that might not have native support, but you have a workaround available.

---

<div class="post-metadata">

**Author:** ![drunyak](https://avatars.discourse-cdn.com/v4/letter/d/ba8739/32.png) [@drunyak](https://community.postman.com/u/drunyak)\
**Post date:** [November 18, 2020, 2:56pm UTC](https://community.postman.com/t/how-i-can-rewrite-collection-value-via-newman/17828/3 "2020-11-18T14:56:06Z")

</div>

Is it working for collection variables???

---

<div class="post-metadata">

**Author:** ![allenheltondev](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/allenheltondev/32/31738_2.png) [@allenheltondev](https://community.postman.com/u/allenheltondev)\
**Post date:** [November 18, 2020, 3:58pm UTC](https://community.postman.com/t/how-i-can-rewrite-collection-value-via-newman/17828/4 "2020-11-18T15:58:19Z")

</div>

How are you running newman?

Are you giving it a json file for the collection or are you giving it the link to pull the current version of the collection?

Either way the answer is no, but we can figure out what you need to do based on your answer here.

---

<div class="post-metadata">

**Author:** ![drunyak](https://avatars.discourse-cdn.com/v4/letter/d/ba8739/32.png) [@drunyak](https://community.postman.com/u/drunyak)\
**Post date:** [November 18, 2020, 7:34pm UTC](https://community.postman.com/t/how-i-can-rewrite-collection-value-via-newman/17828/5 "2020-11-18T19:34:08Z")

</div>

I want to update the value of collection variable when running newman or node js

---

<div class="post-metadata">

**Author:** ![allenheltondev](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/allenheltondev/32/31738_2.png) [@allenheltondev](https://community.postman.com/u/allenheltondev)\
**Post date:** [November 18, 2020, 8:34pm UTC](https://community.postman.com/t/how-i-can-rewrite-collection-value-via-newman/17828/6 "2020-11-18T20:34:29Z")

</div>

Are you passing in json or are you passing in a url for your collection?

---

<div class="post-metadata">

**Author:** ![drunyak](https://avatars.discourse-cdn.com/v4/letter/d/ba8739/32.png) [@drunyak](https://community.postman.com/u/drunyak)\
**Post date:** [November 18, 2020, 8:47pm UTC](https://community.postman.com/t/how-i-can-rewrite-collection-value-via-newman/17828/7 "2020-11-18T20:47:19Z")

</div>

We wanna use json, cause our developers would like to update value of collection variable. The idea is developers doesn’t use postman. Postman only for testers

---

<div class="post-metadata">

**Author:** ![allenheltondev](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/allenheltondev/32/31738_2.png) [@allenheltondev](https://community.postman.com/u/allenheltondev)\
**Post date:** [November 18, 2020, 11:29pm UTC](https://community.postman.com/t/how-i-can-rewrite-collection-value-via-newman/17828/8 "2020-11-18T23:29:16Z")

</div>

If you’re passing in static json as your collection, there’s not going to be a way for you to update those variables.

Have you considered moving the collection variables to an environment instead?

---

<div class="post-metadata">

**Author:** ![drunyak](https://avatars.discourse-cdn.com/v4/letter/d/ba8739/32.png) [@drunyak](https://community.postman.com/u/drunyak)\
**Post date:** [November 19, 2020, 7:02am UTC](https://community.postman.com/t/how-i-can-rewrite-collection-value-via-newman/17828/9 "2020-11-19T07:02:00Z")

</div>

Yes, I have. But it’s not a good idea, because if I wanna use this collection tests on different environments… UPD : We have decided to use global variable.
