【Postman】ResponseHeader中提取cookie
实现接口自动化关键一步,将login中的cookie提取出来,设置成变量,为调用下一个接口做准备。
接口返回的Response Headers如下
Response Headers
Server: nginx/1.11.11
Date: Fri, 27 Nov 2020 08:53:29 GMT
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
Cache-Control: private, no-store, no-cache, must-revalidate
Authorization: Bearer 311e8378-51c1-42e5-b1eb-5e056861ad81
Set-Cookie: Authorization=311e8378-51c1-42e5-b1eb-5e056861ad81; Path=/; HttpOnly; SameSite=Lax
Content-Encoding: gzip
直接在Tests模块写脚本如下
var jsondata = postman.getResponseHeader("set-cookie");//获取R