gpt4 book ai didi

postman - 如何从 POSTMAN 中的请求正文中提取特定值并保存在变量中

转载 作者:行者123 更新时间:2023-12-04 01:28:05 25 4
gpt4 key购买 nike

有没有办法从请求正文中获取特定值( businessType )并保存在 postman 的变量中?

请求正文

{
"fein": "nurrk",
"businessType": "LLP",
"incorporationYear": 1993,
"incorporationState": "stateelesss",
"annualRevenue": 1000,
"companyActivity": "Producctiionn",
"stockSymbol": "starer",
"mcc": "qa12345"
}

POSTMAN SS

我一直在使用不同的命令,但它们似乎都不起作用
var reqBody = JSON.parse(request.data);

最佳答案

您可以使用 pm.request从请求正文中获取数据:

let businessType = JSON.parse(pm.request.body.raw).businessType;

pm.environment.set('businessType', businessType);

更多信息 pm.* API可以在这里找到:

https://learning.postman.com/docs/postman/scripts/postman-sandbox-api-reference/

关于postman - 如何从 POSTMAN 中的请求正文中提取特定值并保存在变量中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61480854/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com