如何检索表单数据的键值对并在Postman测试脚本中使用它

huangapple go评论79阅读模式
英文:

How to retrieve body form-data in key value pair and use it in postman test script

问题

I tried the following but did not work:
尝试了以下方法,但未成功:
pm.request.body.data

pm.request.data

英文:

request body form-data

I tried the following but didnot work
pm.request.body.data

pm.request.data

答案1

得分: 1

  1. 访问这种格式

pm.request.body.formdata.get("name")
pm.request.body.formdata.get("last_name")
pm.request.body.formdata.get("other_name")

  1. [文档在这里](https://www.postmanlabs.com/postman-collection/RequestBody.html)

formdata:PropertyList.
此请求的表单数据参数存储在此字段中。

类型:PropertyList.

  1. [![在这里输入图片描述][1]][1]
  2. `Tests` 选项卡中的用法。
  3. [![在这里输入图片描述][2]][2]
  4. [1]: https://i.stack.imgur.com/8S8K1.png
  5. [2]: https://i.stack.imgur.com/ppMS1.png
英文:

Access this format

  1. pm.request.body.formdata.get("name")
  2. pm.request.body.formdata.get("last_name")
  3. pm.request.body.formdata.get("other_name")

Documentation in here

  1. formdata :PropertyList.<FormParam>
  2. Form data parameters for this request are held in this field.
  3. Type:
  4. PropertyList.<FormParam>

如何检索表单数据的键值对并在Postman测试脚本中使用它

Usage in Tests tab.

如何检索表单数据的键值对并在Postman测试脚本中使用它

huangapple
  • 本文由 发表于 2023年2月17日 23:54:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/75486512.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定