Skip to main content

Report Postman Test Results to Vansah

Connect Postman requests to Vansah Test Cases, send Passed or Failed results, and verify that each Test Run was saved.

Send the result of a Postman request to a linked Vansah Test Case. This example runs your assertions, records Passed or Failed, and checks that Vansah saved the Test Run.

Before you begin

  • Create a Test Case linked to the Jira work item you want to test. The account needs Jira space access and Vansah permission to execute Test Cases.

  • Copy your Vansah API Connect URL and create a Vansah API token. Keep the token private.

Each enabled request creates a new Test Run. This example records an overall result; it does not upload each assertion as a Vansah step log.

1. Configure a Postman environment

  1. Create or select an environment.

  2. Add the variables below with values from your own Jira space.

  3. Keep reporting disabled while editing.

Variable

Value

Purpose

Vansah_URL

Your API Connect URL

Base URL without a trailing slash.

VANSAH_TOKEN

Your private API token

Direct Authorization header; no Bearer prefix.

VANSAH_CASE_KEY

DEMO-C46

Existing linked Test Case.

VANSAH_ISSUE_KEY

DEMO-123

Existing Jira work item.

sendResultstoVansah

0 or 1

Disable or enable reporting.

EnvironmentName

UAT

Optional environment name; supply if mandatory.

ReleaseName

1.0

Optional existing Jira release name; supply if mandatory.

SprintName

Sprint 1

Optional existing Jira sprint name; supply if mandatory.

These screenshots show an older layout. Copy your own workspace URL; the host shown is an example.

API Connect URL above the Vansah API token list

Selecting a Postman environment and adding Vansah_URL

2. Add the post-response script

Endpoint: POST /api/v2/run

Open the request and select Scripts → Post-response (called Tests in older Postman versions). Add the script below and replace the two sample assertions with checks for your API.

Put every synchronous assertion that should affect the Vansah result inside check(...). This example does not aggregate assertions elsewhere, collection-level or asynchronous checks, or requests that receive no response.

let result = "passed";
function check(name, assertion) {
pm.test(name, function () {
try { assertion(); }
catch (error) { result = "failed"; throw error; }
});
}

// Replace these checks with the assertions for this request.
check("Response status is 200", () => pm.response.to.have.status(200));
check("Response time is below 2 seconds", () =>
pm.expect(pm.response.responseTime).to.be.below(2000));

if (String(pm.environment.get("sendResultstoVansah")) === "1") {
const read = name => String(pm.environment.get(name) || "").trim();
const urlValue = read("Vansah_URL");
const baseUrl = urlValue.endsWith("/") ? urlValue.slice(0, -1) : urlValue;
const token = read("VANSAH_TOKEN");
const caseKey = read("VANSAH_CASE_KEY");
const issueKey = read("VANSAH_ISSUE_KEY");
if (!baseUrl || !token || !caseKey || !issueKey) {
throw new Error("Set the Vansah URL, token, Test Case key, and Jira work item key.");
}
const properties = {};
for (const [field, variable] of [
["environment", "EnvironmentName"],
["release", "ReleaseName"],
["sprint", "SprintName"]
]) {
const name = read(variable);
if (name) properties[field] = { name };
}
const payload = {
asset: { type: "issue", key: issueKey },
case: { key: caseKey },
result: { name: result },
properties
};
pm.test("Vansah saved the Test Run", function (done) {
pm.sendRequest({
url: baseUrl + "/api/v2/run",
method: "POST",
header: {
Authorization: token,
"Content-Type": "application/json",
Accept: "application/json"
},
body: { mode: "raw", raw: JSON.stringify(payload) }
}, function (error, response) {
try {
if (error) throw error;
pm.expect(response.code).to.equal(200);
const body = response.json();
pm.expect(body.success, body.message).to.equal(true);
pm.expect(body.data.run.key).to.be.a("string").and.not.empty;
console.log("Vansah Test Run:", body.data.run.key);
done();
} catch (reportError) { done(reportError); }
});
});
}

For multiple requests, give each its own Test Case mapping. A collection-level script with one shared case key creates runs for that same case after each request.

3. Run and verify

  1. Select the environment and set sendResultstoVansah to 1.

  2. Send the request. Check your API assertions and Vansah saved the Test Run in Test Results.

  3. Open the linked Test Case in Vansah and verify the run, result, and properties.

  4. Set reporting back to 0 while changing the script.

Rerunning creates another run. If reporting times out, check Vansah before retrying because the run may already have been saved.

Troubleshooting

Problem

What to check

No run

Selected environment, reporting enabled, exact keys, case linked and not blocked.

Authentication or permission error

Token validity, workspace URL, Jira space access and execute permission.

Validation error

Current workspace result names, exact existing release/sprint names and mandatory properties.

API checks pass; reporting fails

Review the separate reporting assertion and response message. API success does not prove the result was saved.

For Test Folder or Test Plan runs, use the shapes in Create a Test Run. Do not put a folder path in the Jira work item variable.

Did this answer your question?