【发布时间】:2021-02-05 06:02:37
【问题描述】:
我已经在我的颤振应用程序中成功使用了 woocommerce 的 rest api,但我被困在一个点,即通过 woocommerce rest API 在 json 文件中添加 line_items。
List<CartPdt>linecartitems=[];
linecartitems.map((i)=>{
'product_id':int.parse(i.id),
'quantity':i.quantity
}).toList();
var lc=json.encode(linecartitems);
var createOrderUrl = await http.post(
'url',
body: json.encode({
'billing': {
'first_name': fname,
'last_name': lname,
'email': email,
'address': address,
'city': city,
'phone': phone
},
'line_items':lc,
}),
headers: {"Content-Type": "application/json"},
);
【问题讨论】:
-
请说明您遇到的错误或问题。
-
"line_items":"line_items[0] 不是对象类型。这是我遇到的错误。
-
你可以看看这个答案:stackoverflow.com/a/55025048/10659482
标签: flutter woocommerce-rest-api