Add the below code in the Pre-request Script tab
pm.sendRequest({
url: "http://localhost:8080/login",
method: 'POST',
header: {'Content-Type': 'application/json'},
body: {
mode: 'raw',
raw: JSON.stringify({
username: postman.getEnvironmentVariable("username"),
password:postman.getEnvironmentVariable("password") })
}
}, function (err, res) {
postman.setEnvironmentVariable("userId", res.json().userId);
});
Reference: https://gist.github.com/madebysid/b57985b0649d3407a7aa9de1bd327990
pm.sendRequest({
url: "http://localhost:8080/login",
method: 'POST',
header: {'Content-Type': 'application/json'},
body: {
mode: 'raw',
raw: JSON.stringify({
username: postman.getEnvironmentVariable("username"),
password:postman.getEnvironmentVariable("password") })
}
}, function (err, res) {
postman.setEnvironmentVariable("userId", res.json().userId);
});
Reference: https://gist.github.com/madebysid/b57985b0649d3407a7aa9de1bd327990
No comments:
Post a Comment