Andromeda
Andromeda

Reputation: 11

Running a request from postman testscript of another request

Requirement:There are 2 requests, request A and request B. I need to run Request A when a condition specified in the test script of Request B is attained in POSTMAN. I used the below code, but while running, in the console I am getting "Status" : "Unauthorized". The authorization method is bearer token and i have put the token in the collection authorization tab. In the request I have chosen the Inherit from parent. But I am not sure how or where to put the authorization details while running the request from the Test script. Please let me know the solution. var request = { method: 'POST', url: 'https://', // Replace with your failure endpoint URL headers: { 'Content-Type': 'application/json', 'Accept':'application/json', 'Authorization':'Bearer 324ghvvj23vhvhjvhjvjhvjhvhjvj' // Add any additional headers as needed }, }; // Send the request pm.sendRequest(request, function (err, res) { if (err) { console.error(err); return; } console.log('Request sent successfully:', res); });

Upvotes: 0

Views: 24

Answers (0)

Related Questions