【发布时间】:2017-07-24 20:04:48
【问题描述】:
我正在执行一个 http 请求并将一个数组列表传递给一个 formUrlEncoded 属性,但这失败了
public static async Task<HttpResponseMessage> SubmitInspection(
TruckRegistrationDetails truckdetails
List<CommentModel> check_comments,
String general_comment)
{
var body= new ArrayList(){ truckdetails, check_comments, general_comment };
var body = new FormUrlEncodedContent(body); //this fails
//get url from SQLite
var response = await http.PostAsync(url, body);
return response;
}
我得到一个错误:
无法从“System.Collections.ArrayList”转换为 'System.Collections.Generic.IEnumerable'
如何将传递的不同参数类型添加到formUrlEncoded
【问题讨论】:
-
除了错误之外,您还需要确切地知道要传递给 PostAsync 方法的内容。它必须是接收器可以使用的格式。然后,您需要将一个或多个键值对传递给数组中的 PostAsyn 方法或实现 IEnumerable 的东西。您对需要通过的内容和格式有任何要求吗?
-
我看到@CodingYoshi 接收器是 php,它需要一个数组或一个对象
标签: c# arraylist uwp win-universal-app