New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extra argument 'method' in call #1508
Comments
First of all : don't post this here, post it on Stack Overflow and tag it with Alamofire (I'm also monitoring those so you'd get the same answer but others could see it). As stated in the README, Github is for bugs and this isn't one. |
I'm getting the same issue, with the same error message ("Extra argument 'method' in call"), with correct
|
I'm quite sure, because I'm able to reproduce the issue and fix it with all three options I presented. Nevertheless, I'm happy to help you out if you could post the surrounding code to reproduce the issue with |
@thebluepotato Thanks for clarifying when to use Stackoverflow and when to use GitHub. Turns out my original error was that I was trying to pass a URLRequest and not a URLConvertible. While reproducing I ended up with the string i presented when creating this topic which only led to more confusion. But now it works for me. Thank you. |
If you can give a hand even though the issue belongs on Stackoverflow, I truly appreciate it - here's the code I'm running (using Alamofire 4.0.0):
The request sends a UTF8 string to an AV receiver to control the input, volume etc, depending on the content of the string. The code above results in the "Extra argument 'method' in call" error whether I include the I used the exact same code successfully yesterday, using the swift3 branch via Cocoapods. |
@otherbuns Take a look at our migration guide you'll see that our parameter encoding methods have radically changed for Alamofire 4. You no longer need to use the ugly |
@otherbuns Any time one argument is of the wrong type, the Swift interpreter here believes that you're wrongly using |
Now that you point it out, I really wonder how I managed to miss it. Thanks a lot for your help, even if the answer was right before my nose! |
@thebluepotato Thank you for clarifying about Swift's non helpful response. My issue was that Alamofire will not accept parameters which are arrays of the form |
Hi, guys. I should must use array value([Int]) for parameter. How to solve my problem? |
Hi Guys: |
Hey @kevinlee85, the easiest way to fix your issue is to comment the code out and rebuild it with auto-complete. The error is usually pretty obvious when you do it that way. |
This one worked for me. Swift 3.0 Alamofire.request("https://yourServiceURL.com", method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: nil).responseJSON { (response:DataResponse) in
and make sure that the parameters are of type [String:Any]? Alamofire.request("https://yourGetURL.com", method: .get, parameters: ["":""], encoding: URLEncoding.default, headers: nil).responseJSON { (response:DataResponse) in
Even works with JSONEncoding.default 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-protocol |
@cnoon I'm having the same problem. I read the doc and added extra struct as suggested in the readingMe.
} request = customAlamofireManager.request( Same error, because param is not a dictionary. However there need a way to pass in this array param. I'm also having another Struct to make Gzip array of objects. I get the same error as this one. There must be a way to pass in body data for encode. |
@thebluepotato Did as same as the instruction suggested, but how to pass in the array parameter? Thanks |
Answer my own question here, find a way to pass in custom encoded request to Alamofire.DataRequest to escape the above mentioned method with parameters, which is not used anyway.
... |
FTR, this happened to me when i was using an optional variable in the parameters attribute |
@popsware You can use the method I mentioned above to avoid that. It works. |
if you use headers you must define |
As @Innolabdev mentioned, |
Okay, I find a interesting problem: ( I use swift4 and Alamofire4.7) |
@ExplosiveBattery |
This line doesn't work on 4.0.0:
Alamofire.request("https://httpbin.org/post", method: .post, parameters: [], encoding: JSONEncoding.default)
I get "Extra argument 'method' in call" error.
I'm using XCode8 GM and your latest version.
The text was updated successfully, but these errors were encountered: