Pass a token from the login request to the next one
QuizMediumAsked in: Capgemini, Infosys
The login response body is {"token": "abc123"}. How do you make later requests in the collection send it?
- In the login request's post-response script: pm.collectionVariables.set("token", pm.response.json().token); then later requests use Authorization: Bearer {{token}}
- Copy the token by hand into every request
- Put {{token}} in the login request body
- pm.response.token("token")
This question is part of Pro+
Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.