Ragova
Ragova

Reputation: 95

Extract cookie value from request (POSTMAN/JMETER)

How can I Extract these three cookies from a request and pass them as headers in second request

First Request: First request

Second Request: Second request

Upvotes: 6

Views: 14452

Answers (2)

Dmitri T
Dmitri T

Reputation: 168207

For JMeter:

  1. Add the next line to user.properties file:

    CookieManager.save.cookies=true
    
  2. Restart JMeter to pick the property up.

    This way JMeter will store all cookie values as JMeter Variables.

  3. Add HTTP Header Manager as a child of the 2nd request and configure it as follows:

    • Name: XCSRFToken
    • Value: ${COOKIE_XCSRFToken}

      JMeter Cookies As a Header

See HTTP Cookie Manager Advanced Usage - A Guide article for more HTTP Cookie Manager tips and tricks.

Upvotes: 1

Danny Dainton
Danny Dainton

Reputation: 25921

Try using the pm.cookies.get() function to extract the cookie values that you require:

Postman Docs

This can then be set in an environment or global variable and using it in any request you want.

This is an example using the jsonplaceholder site and logging the cookie value to the Postman console.

Postman

You could then use the pm.environment.set('my_cookie', pm.cookies.get('cookie_value')) function and store it as an environment variable. This can then be used in the next/any request's Header by referencing it with the {{my_cookie}} syntax.

Postman

Upvotes: 8

Related Questions