postmanpostman-collection-runner

Coerce the Postman Cli to yield the response payload after a collection request?


The postman cli does yield this information after a collection request, but as of now I must parse it:

  ┌ ↓ application/json ★ text ★ json ★ utf8 ★ 74B
  │ {"error":"yak fur overgrowth","error_description":"yak fur obscures the horizon and the stars"}
  └

The JSON might always be one line or it could be many lines; it might wind up being easy or hard, but I'd prefer not to find out.

Is there a way to coerce postman to deliver its payload in plain JSON? My current command looks like:

postman collection run --verbose --env-var foo=bar <my-collection-id> -e <my-env-id> -i <my-request-id>

Solution

  • If you're talking about those annoying vertical bars that appear to the left of Postman CLI output, I use a postman test to get the same output but without those bars, making the output copyable:

    var response = JSON.parse(responseBody);
    // allow the response to be copy-able... 
    // ...via Postman CLI
    pm.test(response, function () {
        pm.expect(response).not.equal(undefined);
    });
    // ...via Postman UI
    console.log(response);