# After run collection with powershell/Newman, can we parse error

**URL:** <https://community.postman.com/t/after-run-collection-with-powershell-newman-can-we-parse-error/69529>\
**Category:** Help Hub\
**Tags:** newman-project, assertionerror, command-line\
**Created:** [October 10, 2024, 2:52pm UTC](https://community.postman.com/t/after-run-collection-with-powershell-newman-can-we-parse-error/69529 "2024-10-10T14:52:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![greenridinghood](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/greenridinghood/32/26145_2.png) [@greenridinghood](https://community.postman.com/u/greenridinghood)\
**Post date:** [October 10, 2024, 2:52pm UTC](https://community.postman.com/t/after-run-collection-with-powershell-newman-can-we-parse-error/69529/1 "2024-10-10T14:52:49Z")

</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).

Is there any way that after run the collection with Powershell/Newman and parse(take just that part) the error part and save at another file?

I am running my test collection in azure pipeline, for that I used newman scripts. But now I need to extract errors and create API calls for each error line. For the first step, I was planning to extract every error end of the automation test. After extracting that (maybe in another file), I plan to read each error and call API after each line.

`newman run "collection_name.postman_collection.json" --environment "DEV.postman_environment.json" ` =\> probably I need to add something for extract just errors

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/9/6/960d77dce858b0ea21bf5fcc9d1aa235158b6362.png)

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [October 14, 2024, 4:45pm UTC](https://community.postman.com/t/after-run-collection-with-powershell-newman-can-we-parse-error/69529/2 "2024-10-14T16:45:18Z")

</div>

Hey @greenridinghood 👋

Might not be what you’re looking for but you can use [Newman as a library](https://github.com/postmanlabs/newman?tab=readme-ov-file#using-newman-as-a-library), to access the run summary object.

You can use the different `on` events to access part of the data like the error messages:

> **[GitHub - postmanlabs/newman: Newman is a command-line collection runner for...](https://github.com/postmanlabs/newman?tab=readme-ov-file#newmanrunevents)**
>
> Newman is a command-line collection runner for Postman

A basic example script:

```auto
const newman = require('newman');

newman.run({
    collection: require('collection.json')
}).on('assertion', function (err, args) {
    console.log(args.error.message);
})

```

When run it pushed the failed messages to the console but you could point it to some place else and not the console.

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/3/3/3353f978c06872d84fd5d2a8f92ac58beb8c89a5.png)

Might not be what you’re looking for but that’s one of the ways to access the run data when using Newman.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [November 13, 2024, 4:45pm UTC](https://community.postman.com/t/after-run-collection-with-powershell-newman-can-we-parse-error/69529/3 "2024-11-13T16:45:36Z")

</div>

Closed on November 13, 2024, 4:45pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
