本文介绍了从请求中提取Cookie值(POSTMAN/JMETER)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从请求中提取这三个Cookie并将其作为标头传递给第二个请求

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

第一个请求:

第二个请求:

推荐答案

尝试使用 pm.cookies.get()函数提取所需的Cookie值:

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

然后可以在environmentglobal变量中进行设置,并在需要的任何请求中使用它.

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

这是一个使用 jsonplaceholder 网站并将Cookie值记录到Postman控制台的示例.

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

然后可以使用pm.environment.set('my_cookie', pm.cookies.get('cookie_value'))函数并将其存储为环境变量.然后,可以使用{{my_cookie}}语法对其进行引用,将其用于下一个/任何请求的Header.

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.

这篇关于从请求中提取Cookie值(POSTMAN/JMETER)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 02:53