是否可以使用 Postman Chrome 扩展程序发送数组? [英] Is it possible to send an array with the Postman Chrome extension?

查看:27
本文介绍了是否可以使用 Postman Chrome 扩展程序发送数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用 Postman Chrome 扩展程序来测试我的 API,并想通过邮寄方式发送一组 ID.有没有办法在 Postman 中发送一些列表作为参数?

I've been using Postman Chrome extension to test out my API and would like to send an array of IDs via post. Is there a way to send something list this as a parameter in Postman?

{
  user_ids: ["1234", "5678"]
}

推荐答案

你需要在你的变量名后面加上 [] 像这样:

You need to suffix your variable name with [] like this:

如果这不起作用,请尝试不要将索引放在括号中:

If that doesn't work, try not putting indexes in brackets:

my_array[]  value1
my_array[]  value2

<小时>

注意:

  • 如果您使用 邮递员打包的应用程序,你可以通过选择raw/json(而不是form-data)来发送一个数组.另外,请确保在 Headers 选项卡中将 Content-Type 设置为 application/json.这是原始数据的示例 {"user_ids": ["123" "233"]},不要忘记引号!

  • If you are using the postman packaged app, you can send an array by selecting raw / json (instead of form-data). Also, make sure to set Content-Type as application/json in Headers tab. Here is example for raw data {"user_ids": ["123" "233"]}, don't forget the quotes!

如果您使用的是 邮递员 REST客户端 你必须使用我上面描述的方法,因为将数据作为原始(json)传递是行不通的.postman REST 客户端存在一个错误(至少我在使用 0.8.4.6 时得到了这个错误).

If you are using the postman REST client you have to use the method I described above because passing data as raw (json) won't work. There is a bug in the postman REST client (At least I get the bug when I use 0.8.4.6).

这篇关于是否可以使用 Postman Chrome 扩展程序发送数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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