How to run one request from another using Pre-request Script in Postman
Solution 1:
As mentioned by KBusc and inspired from those examples you can achieve your goal by setting a pre-request script like the following:
pm.sendRequest({
url: pm.environment.get("token_url"),
method: 'GET',
header: {
'Authorization': 'Basic xxxxxxxxxx==',
}
}, function (err, res) {
pm.environment.set("access_token", res.json().token);
});
Then you just reference {{access_token}}
as any other environment variable.
Solution 2:
A little late but for others who come across this post, it IS now possible to send another request from the Pre-request Script
section. A few examples can be found here : https://gist.github.com/madebysid/b57985b0649d3407a7aa9de1bd327990