title: How to retrieve and add xsrf cookies to a REST client call?
body: <p>I am using RESTAssured for my api testing. When I test the API login endpoint using Postman, I get cookies for anti-forgery which the Postman (and the browser) uses with every call when using the application.</p>
  
  <p>To replicate this behavior for API testing, I can make the call to authenticate but RESTAssured does not retrieve the cookies sent by the server same way Postman does.</p>
  
  <p>How do I go about retrieving the cookies for subsequent API calls?</p>
  
  <p>I have so far tried Postman and RESTAssured but can be flexible on the API testing library.</p>
  
  <pre><code>httpReq = RestAssured.given().log().all();
  httpReq.contentType(ContentType.URLENC.withCharset("UTF-8"));
  httpReq.formParam("Email", email);
  httpReq.formParam("Password", password);
  httpReq.formParam("__RequestVerificationToken", substr);
  
  Map&lt;String, String&gt; authCookies = response.getCookies();
  </code></pre>
  
  <p>When I debug and watch authCookies, it is missing the relevant anti-forgery tokens. Adding the authCookies to subsequent requests results in 401 Bad Request.</p>