使用 Postman 获取和存储 cookie 的值 [英] Get and store the value of a cookie using Postman

查看:68
本文介绍了使用 Postman 获取和存储 cookie 的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要获取 cookie 的值,该值仅在我在 postman 中发送请求时创建.

我已经尝试了一切,但我不知道如何实现这一点.我还需要存储该值以用于我的项目的进一步请求.

cookie 名称:JSESSIONID值:09840****************00C44

解决方案

你可以使用 pm.environment.set('my_cookie', pm.cookies.get('JSESSIONID')) 函数在 Tests 选项卡中,并将其存储为 environment 变量.

然后可以通过使用 {{my_cookie}} 语法在下一个/任何请求正文或请求标头等中使用它.

可以在此处找到一个非常相似的问题..p>

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

解决方案

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.

这篇关于使用 Postman 获取和存储 cookie 的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆