Postman

How to automatically get an authorization token in a Postman pre-request script

If you need to add an authorization token to each endpoint call in Postman, you can do it by using the following pre-request script:

pm.sendRequest({
    url: "",
    method: 'POST',
    header: {
        'Accept': 'application/json',
    },
    body: {
        mode: 'raw',
        raw: JSON.stringify()})
    }
}, function (err, res) {
    pm.environment.set("headerName", res.headers.get("headerName");
});