gpt4 book ai didi

json - 如何在 MultipartRequest 中发送数组?

转载 作者:行者123 更新时间:2023-12-05 01:34:26 25 4
gpt4 key购买 nike

这是我正在使用 postman 作为数组测试我的 api

enter image description here

但是我如何使用 MultipartRequest 发送数组

var uri = Uri.parse(Constants.BASEURL + Constants.KEYEORD_CREATE_TENANACY);
Map<String, String> headers = {
"Accept": "application/json",
"Authorization": token
};
var request = new http.MultipartRequest("POST", uri);
request.headers.addAll(headers);
request.fields['property_usage'] = property_use;
request.fields['unit_id'] = unitlist; // here i want unit_id to array
var response = await request.send();
print("Tenancy Add Result: ${response.statusCode}");
if (response.statusCode == 200) {
print(response);
}

最佳答案

'''

request.fields['unit_id[n]'] = "${arrUnitlist[n]}";

for(int i = 0; i < arrUnitlist; i++){
request.fields['unit_id[$i]'] = '${arrUnitlist[i]}';
}

'''

对我有用

关于json - 如何在 MultipartRequest 中发送数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63654362/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com