I have read all the questions on this issue this and this. I have the following code
let fullURL = God.getFullURL(apiURL: self.apiUrl)
if (getOrPost == God.POST) {
Alamofire.request(fullURL, method: .POST, AnyObject: self.postData?, encoding:.JSONEncoding.default, headers: nil).responseJSON{ response in
self.responseData = response.result.value
}
} else if (getOrPost == God.GET) {
Alamofire.request(fullURL, method : .GET, Parameters: getData, encoding:.JSONEncoding.default, headers: nil).responseJSON{ response in
self.responseData = response.result.value
}
}
My Swift and Xcode versions are
Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1)
Target: x86_64-apple-macosx10.9
Version 8.2.1 (8C1002)
My pod file is
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
target 'Buseeta' do
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :branch => 'master'
end
pod 'AlamofireObjectMapper', '~> 4.0'
pod 'SwiftyJSON'
I get Extra argument 'method' in call
error on both Alamofire request lines.
Dont go mark this question as duplicate without carefully checking. I have fixed the code exactly as per the duplicate questions.
EDIT 1
I tried after removing the headers, same issue on .POST
and .GET
let fullURL = God.getFullURL(apiURL: self.apiUrl)
if (getOrPost == God.POST) {
Alamofire.request(fullURL, method: .POST, AnyObject: self.postData?, encoding:.JSONEncoding.default).responseJSON{ response in
self.responseData = response.result.value
}
} else if (getOrPost == God.GET) {
Alamofire.request(fullURL, method : .GET, Parameters: getData?, encoding:.JSONEncoding.default).responseJSON{ response in
self.responseData = response.result.value
}
}
EDIT 2
if (getOrPost == God.POST) {
Alamofire.request(fullURL, method: .post, parameters: self.postData?, encoding:.JSONEncoding.default).responseJSON{ response in
self.responseData = response.result.value
}
} else if (getOrPost == God.GET) {
Alamofire.request(fullURL, method : .get, parameters: getData?, encoding:.JSONEncoding.default).responseJSON{ response in
self.responseData = response.result.value
}
}
EDIT 3
I replaced with method : HTTPMethod.get,
still no change. Same issue.
See Question&Answers more detail:
os