Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel csrf token mismatch postman

// Laravel csrf token mismatch postman -- For POSTMAN Pre-request-script --
// YOUTUBE (NOT MY VIDEO!) : https://youtu.be/EgBq4IVnfnA

// But the code is mine! :D 

// POSTMAN Collection -> Pre-request-script. 
// Will look like this :
pm.sendRequest({
  url: 'https://bla-bla-bla.co.za/sanctum/csrf-cookie',
  method: 'GET'
}, function(error, response, {cookies}){
  console.log(cookies);// This will console.log your cookies rsponse in POSTMAN
  pm.collectionVariables.set('aaa-var-name-csrf-token', cookies.get('XSRF-TOKEN'));
}); 

// Step 2
// You need to create a collection variable for your newly created variabe name
/// Collection Headers... /// 
bearer_token : ...
bbb-csrf-token : {{aaa-var-name-csrf-token}}
base_url : ...
whatever-whatever... : ...

// Step 3
// You need to now add your collection variable to your request
// You can do this by adding to your request headers and using the variable 
// name you created for your csrf-token. In this case -> "var-name-csrf-token"
/// Request Headers... ///
X-XRSF-TOKEN : {{bbb-csrf-token}}
 
PREVIOUS NEXT
Tagged: #laravel #csrf #token #mismatch #postman
ADD COMMENT
Topic
Name
6+1 =