I need to get the value of a cookie, that is only created when I send a request in postman.
I have tried everything but I don't know how to achieve this. I also need to store that value to use in further requests for my project.
cookie name: JSESSIONID
value:09840****************00C44
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.
Postman's cookie manager enables you to view and edit cookies that are associated with different domains. You can manually create cookies for a domain, or you can capture cookies using the Postman proxy or Postman Interceptor. You can then use the cookies stored in the cookie jar when sending requests in Postman.
Postman stores cookies inside a Cookie Manager and the stored cookies can be accessed when writing scripts in Postman. The access to cookies inside scripts is exposed thanks to a cookie jar, and you can use that cookie jar to work with cookies inside your scripts. Select a request > Cookies.
You could use the pm.environment.set('my_cookie', pm.cookies.get('JSESSIONID'))
function in the Tests
tab and store it as an environment
variable.
This can then be used in the next/any Request Body or Request Header etc by referencing it using the {{my_cookie}}
syntax.
A very similar issue can be found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With