Skip to content

Instantly share code, notes, and snippets.

@kgilpin
Last active July 14, 2022 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kgilpin/17a3ca05b51b9b7dab9d3a4a73718ef8 to your computer and use it in GitHub Desktop.
Save kgilpin/17a3ca05b51b9b7dab9d3a4a73718ef8 to your computer and use it in GitHub Desktop.
Rails Sample App 6th Ed Postman Pre-request script
pm.sendRequest(pm.variables.get('baseUrl'), function (err, response) {
const token = /meta\s+name="csrf-token"\s+content="(.*)"/.exec(response.text());
console.log(`CSRF protection: ${token}`);
if( token) {
pm.globals.set('authenticity_token', token[1]);
}
})
@kgilpin
Copy link
Author

kgilpin commented May 25, 2022

Invoke like this:

Screen Shot 2022-07-14 at 12 58 45 PM

@kgilpin
Copy link
Author

kgilpin commented May 25, 2022

Configure like this:

Screen Shot 2022-07-14 at 12 57 17 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment