我有一个POST API
,其中我发送了多个参数,其中一个参数必须是array
dictionaries
。
let arr = [
[
"id" : "1",
"price" : "10"
],
[
"id" : "2",
"price" : "20"
]
]
let params : Parameters = [
"param1" : "anyvalue1",
"param2" : "anyvalue2",
"param3" : arr,
]
当我在Alamofire Request
中使用这些参数并点击API时,print(res.result.value)
始终返回未知。谁能帮我这个。以下是请求API的方式
Alamofire.request(url, method:.post, parameters: params).responseJSON{(res) in
print(res.result.value) //always shows 'unknown' as output
}
答案 0 :(得分:0)
尝试使params成为[String:Any]的Dic:
let params : [String:Any] = [
"param1" : "anyvalue1",
"param2" : "anyvalue2",
"param3" : arr,
]