如何在post请求flutter中使用http像这个参数“test_id[]”一样发布列表?

问题描述 投票:0回答:2
'patient_age': patientAge!,
    'test_date': testdate!,
    "test_id[]": testIDs[0].toString(),

我得到的 API 反复使用

test_id[]
来获取正文中的测试 ID 列表,并且在邮递员中,API 测试工作正常。 但是当我在正文中尝试这个
test_id[]
时,它显示地图不接受相同的密钥。我如何以这种模式发送列表?

flutter http postman http-post
2个回答
0
投票

你应该尝试:

"test_id":testIDs
  • 键是test_id
  • 值是testIDs(数据类型是List)

0
投票

http
包中的 HttpClient 不支持此功能(参见 https://github.com/dart-lang/http/issues/47)。

但是,似乎可以使用

dio
包:https://pub.dev/documentation/dio/latest/dio/ListFormat.html

© www.soinside.com 2019 - 2024. All rights reserved.