如何在POST请求中通过邮递员发送数组

时间:2021-02-18 20:32:13

标签: django-rest-framework postman

我想在 POST 请求中通过邮递员发送数组。我想发送这样的数据

{
    "users": [1, 2]
}

我读过这篇文章Is it possible to send an array with the Postman Chrome extension?

并转载,但收到错误(见图)。 我该如何修复错误?

我正在使用 django rest 框架,服务器回答了这个问题

request["users"] is None

enter image description here

1 个答案:

答案 0 :(得分:2)

您不能通过 formdata 发送数组,如果您的端点需要 json 则将其作为 body>raw>json 发送:

enter image description here