1

I use Alamofire 4.0.1 and have this code:

let params = Mapper().toJSON(group)

Alamofire.request("\(Config().apiAdminTableGroup)\(group.id)/", method: .put, parameters: params, headers: Config().apiHeaders, encoding: JSONEncoding.default)
    .responseJSON { response in
        ...
}

But getting this error:

Extra argument 'method' in call

This is by documentation, is this bug or?

Léo Natan
  • 56,823
  • 9
  • 150
  • 195
Mirza Delic
  • 4,119
  • 12
  • 55
  • 86

2 Answers2

2

Check that the structure of your parameters and headers are right, if not the error you mentioned appears. It should look like that:

Alamofire.request("\(Config().apiAdminTableGroup)\(group.id)/", method: .put, parameters: ["param1":"1", "param2":"2"], encoding: JSONEncoding.default, headers: ["Authorization": "Basic xxx"])
ronatory
  • 7,156
  • 4
  • 29
  • 49
  • I have used 'Alamofire.request("", method: .POST, parameters: self.postData, encoding:.JSONEncoding.default).responseJSON{ response in self.responseData = response.result.value } ' still I get the same damn error – Siddharth Feb 08 '17 at 12:26
  • What if you add the `header` parameter? like this: `Alamofire.request("", method: .POST, parameters: self.postData, encoding:.JSONEncoding.default, headers: [:]).responseJSON{ response in self.responseData = response.result.value } ` @Siddharth – ronatory Feb 08 '17 at 12:38
  • same thing.. no change. Btw is it "parameters" or "Parameters" ? – Siddharth Feb 08 '17 at 12:43
  • Its "parameters". Did you check the structure of your paramaters dictionary as I mentioned in the answer?@Siddharth – ronatory Feb 08 '17 at 13:23
  • if I use `parameters` I get use of undeclared type 'parameters`. If I use `Parameters` I dont get that error. For example `var getData : parameters` gives an error. – Siddharth Feb 08 '17 at 13:27
  • ok, I just recommend you to ask a new question with mentioning this answer if you want. It seems also that you don't use the newest version of alamofire, because `.POST` is in uppercase. You should also mention the version for better verifying the problem @Siddharth – ronatory Feb 08 '17 at 13:33
  • http://stackoverflow.com/questions/42113651/swift-3-0-alamofire-4-0-extra-argument-method-in-call?noredirect=1#comment71397619_42113651 – Siddharth Feb 08 '17 at 13:40
0

try this:

Alamofire.request(.PUT, "\(Config().apiAdminTableGroup)\(group.id)/",
                parameters: params).responseJSON { response in
            ...
    }
breno
  • 230
  • 2
  • 15