I am trying to pass array as key in the parameter but i am getting below error:
The underlying encoder failed with the error: invalidRootObject("array([Alamofire.URLEncodedFormComponent.array([Alamofire.URLEncodedFormComponent.string("link")]), Alamofire.URLEncodedFormComponent.string("24")])")
Here is my code for parameter:
let parameters: [[String]: String] = [
["link"]: linkId
]
URLEncoding
handles by default the Array
type as a value of a Dictionary
in parameters (not as a key like in your example code) It even adds the brackets in the key by default.
So, something like this should work fine:
let parameters: [String: Any] = [
"links": [84, 11, 83, 24]
]
AF.request(url, method: .put, parameters: parameters, encoding: URLEncoding.default).response { response in
// ...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.