gpt4 book ai didi

ios - 发送Http.MultipartRequest作为 flutter 数组?

转载 作者:行者123 更新时间:2023-12-03 03:51:15 25 4
gpt4 key购买 nike

这就是我将数据发布到服务器的方式

var request = new http.MultipartRequest("POST", uri);
request.headers.addAll(headers);
request.fields['property_id'] = property_id; //value from textcontroller
request.fields['unit_id'] = unitlist; //value from textcontroller
request.fields['tenant_name'] = tenant_name; //value from textcontroller
request.fields['additional_terms'] = addistiona_tems;//value from textcontroller
var stream = new http.ByteStream(DelegatingStream.typed(file.openRead()));
var length = await file.length();
var tenantimage = new http.MultipartFile('Tenant_image', stream, length,
filename: basename(file.path));
request.files.add(tenantimage);
var response = await request.send();
这是我返回发送值作为响应时的结果
 Array
(
[property_id] => 2
[unit_id] => 1463
[tenant_name] => aqws
[additional_terms] => awedswer
)
但我想实现为“unit_id”和“additional_terms”作为数组?
像这样
 Array
(
[property_id] => 2
[unit_id] => Array
(
[0]
)
[tenant_name] => aqws
[additional_terms] => Array
(
[0]=> awedswer
[1]=> bilk
)
)

最佳答案

试试这个:-

request.fields['additional_terms'] = "[{"shop_id":"1","product_id":1,"unit_price":188.0,"quantity":1,"discounted_price":0.0}]"

关于ios - 发送Http.MultipartRequest作为 flutter 数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63351929/

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