Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 212
Ragova Avatar asked Mar 09 '18 09:03

Ragova


People also ask

How do you get the cookie value in the Postman?

The cookies are mentioned under the Headers and Cookies tab in the Response in Postman. To work with Cookies, we have to click on the Cookies link available under the Params tab. On clicking on it, the MANAGE COOKIES appears. It contains all the available cookies along with the options – Add Cookie and Delete.

How do you get the response body in the Postman?

The Postman Body tab gives you several tools to help you understand the response quickly. You can view the body in one of four views: Pretty, Raw, Preview, and Visualize. in the results pane. You can also place your cursor in the response and select ⌘+F or Ctrl+F.


1 Answers

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

like image 179
Danny Dainton Avatar answered Oct 08 '22 07:10

Danny Dainton