Reputation: 942
I'm trying to authenticate automatically using Paw and to do this I need to
but I don't know how to do that...
Anyone has an idea?
Thanks
Upvotes: 4
Views: 336
Reputation: 2408
In paw first set up the request to the login page. Then in a second request you can asses the response body of the first request: we can use a regex filter on the raw response of another request.
create a custom dynamic value
:
then use the code below to set the custom dynamic value.
function evaluate(context){
// Set up your regex to extract the token
var re = /<h2>([^<]+)<\/h2>/;
// Replace the 'Login page' with your request name
var request = context.getRequestByName('Login page')
var lastExchange = request.getLastExchange()
var body = lastExchange.responseBody
var m = re.exec(body)
return m[1]
};
Upvotes: 3