I am trying to string a few Postman requests together for testing.
-
In the first request I set a global variable as a test script.
tests['Status code is 200'] = (responseCode.code === 200); if (responseCode.code === 200) { try { let jwt = responseBody.replace(/"/g, ''); pm.globals.set("jwt", jwt); console.log("Variable will be set to", jwt); } catch(e) { console.log(e); } } -
In the second request I run a pre-request script as
let jwt = pm.globals.get("jwt");
Then I try to pass it into the header
Is it possible to pass a value into the header?
When running tests the second request fails due to having an invalid jwt, and the Postman docs only show examples passing variables into the URL.

Aucun commentaire:
Enregistrer un commentaire