I have migrated my project to Swift 3 (and updated Alamofire to latest Swift 3 version with pod 'Alamofire', '~> 4.0'
in the Podfile).
I now get an "Extra argument in call" error on every Alamofire.request. Eg:
let patientIdUrl = baseUrl + nextPatientIdUrl
Alamofire.request(.POST, patientIdUrl, parameters: nil, headers: nil, encoding: .JSON)
Can anybody tell me why ?
If you have added Alamofire files locally then don't use "Alamofire" before request
This one worked for me.
No need to remove encoding parameter
Swift 3.x / 4.x
and make sure that the parameters are of type
In case of Get
Even works with
For Headers
If you are passing headers, make sure their type should be
[String:String]
Go through the
Parameter Encoding Link
https://github.com/Alamofire/Alamofire/blob/master/Documentation/Alamofire%204.0%20Migration%20Guide.md#parameter-encoding-protocolI ran into this same Extra argument 'method' in call error when my URL variable was out of scope.
In your case, please make sure both
baseUrl
andnextPatientIdUrl
are in scope when they are being usedAlamofire.request(patientIdUrl,..)
method.Hopefully this resolves your issue. Thanks You!
I just resolved the same problem as you have. The problem is I have imported Alamofire in the header, so I just remove the Alamofire when call request. Like that:
I hope it can help you.
I fixed this issue this way:
Just remove extra parameters, just
parameters
,encoding
andheaders
, if these parameters are nil you can remove then and leave this way,I copy this code from Alamofire,create a URLRequest and used Alamofire.request(URLRequest) method, avoid this error