Search code examples
iosswiftnsdictionaryalamofireswift3

Alamofire 4.0.0: [String:String] is not convertible to [String : Any] & Request is ambiguous without more context


I'm updating Alamofire to 4.0.0 Beta 1 and XCode 8 to Beta 6. First, I got [String:String] is not convertible to [String : Any] error with this code

let parameter = [
        "scope":"\(scope)",
        "client": "\(clientId)"
    ]
Alamofire.request(link, withMethod: .POST, parameters: parameter, encoding: .json).responseJSON

and after I change add [String:Any] to parameter, the error gone but create new error : Expression type 'Request' is ambiguous without more context

let parameter:[String:Any] = [
        "scope":"\(scope)",
        "client": "\(clientId)"
    ]

Solution

  • turns out methods are now lower case, so use .post instead of .POST

    https://github.com/Alamofire/Alamofire/issues/1423