如何解决 django 中的 <Request 400> 错误?

How to solve <Request 400> Error in django?

我试图从我的 Django 项目发出请求。 这是我的代码:

st_data = {"documentId": 1388,
                       "type": 1,
                       "useAsMain": True
                       }

headers2 = {
                'Authorization': 'Bearer ' + token_key,
                "Content-Type": "application/json"

            }

statement = requests.post(url_statement, headers=headers2, data=json.dumps(st_data))

这个请求的响应是 错误代码是:

{"type":"https://tools.ietf.org/html/rfc7231#section-6.5.1","title":"One or more validation errors occurred.","status":400,"traceId":"00-0bbcfce14dfc2146b553c2d98c323b3d-80f72a6fe60f18
4c-00","errors":{"$":["The JSON value could not be converted to System.Collections.Generic.IEnumerable`1[Otc.Data.Objects.StatementDTO]. Path: $ | LineNumber: 0 | BytePositionInLi
ne: 1."]}}

但是当我从 Swagger 发送请求时 UI 喜欢;

它returns <响应200>

我的错误在哪里?

st_data 需要是一个列表,因为它可以在 Swagger UI 示例请求中看到。

st_data = [{"documentId": 1388,
                   "type": 1,
                   "useAsMain": True
                   }]