alamofire

Using FORM DATA with Alamofire

这一生的挚爱 提交于 2019-12-09 15:39:57
问题 I am using alamofire for some time now, but I have never used a form data Post. Now I am stuck. I have 2 params (email, password) and don't know how POST them to server. Can anyone give me an example please? 回答1: And here is a sample code for Alamofire 4.0 in Swift 3.0 let url = "http://testurl.com" let parameters = [ "email": "asd@fgh.hjk", "password": "55555" ] Alamofire.request(url, method: .post, parameters: parameters, encoding: URLEncoding.default).responseJSON { response in switch

Certificate pinning in Alamofire

99封情书 提交于 2019-12-09 12:33:25
问题 I am creating an iPad app that accesses HTTPS web services. I want to implement pinning, but am having issues. This class creates the Alamofire Manager (mostly taken from documentation): class NetworkManager { var manager: Manager? init() { let serverTrustPolicies: [String: ServerTrustPolicy] = [ "www.google.co.uk": .PinCertificates( certificates: ServerTrustPolicy.certificatesInBundle(), validateCertificateChain: true, validateHost: true ), "insecure.expired-apis.com": .DisableEvaluation ]

Multipart-form (image,parameters,headers) Post request with Alamofire in swift

送分小仙女□ 提交于 2019-12-09 10:14:04
问题 Firstly, i want to say i am new to swift, and know a little.So any help would be appriciated. I have a multipart-data form which has a image (profile-image), a few parameters (first-name, last-name) and headers(userid, hashCode). I want to send a POST request to submit the form. I have been able to make POST request with only, headers and other parameters except image as: let headers = [ "user_id": (Helper.getUserInfo()?.user_id)!, "hash_code":(Helper.getUserInfo()?.hash_code)!, ] let params

Cancelling an Alamofire Request Wrapped In NSOperation Causes Multiple KVO?

空扰寡人 提交于 2019-12-09 07:18:22
问题 My Xcode version: 6.3.2 Alamofire version: 1.2.2 (installed via Cocoapods) In order to set maxConcurrentOperationCount to limit the concurrent operation number in a NSOperationQueue , I wrap my Alamofire download request in a NSOperation just like Rob suggested. The basic subclass of NSOperation like this: class ConcurrentOperation : NSOperation { override var concurrent: Bool { return true } override var asynchronous: Bool { return true } private var _executing: Bool = false override var

Send an array as a parameter in a Alamofire POST request

試著忘記壹切 提交于 2019-12-08 23:33:29
问题 My app is currently using AWS API Gateway and Alamofire to access different lambda functions that act as my backend. I have the need to send an array as one of the parameters to one of those API end points, for that I am using the following code: var interests : [String] interests = globalInterests.map({ (interest) -> String in return interest.id! }) // Parameters needed by the API let parameters: [String: AnyObject] = [ "name" : name, "lastName" : lastName, "interests" : interests ] // Sends

unwrapping an Optional value

断了今生、忘了曾经 提交于 2019-12-08 23:17:34
I am trying to login with macbook using code but I keep on getting this error: Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value // API to log an user in func login(userType: String, completionHandler: @escaping (NSError?) -> Void) { let path = "api/social/convert-token/" let url = baseURL!.appendingPathComponent(path) let params: [String: Any] = [ "grant_type": "convert_token", "client_id": CLIENT_ID, "client_secret": CLIENT_SECRET, "backend": "facebook", "token": FBSDKAccessToken.current().tokenString, "user_type": userType ] Alamofire.request(url!, method:

Alamofire Xcode 8 Swift 3 results in 786 compile errors

别来无恙 提交于 2019-12-08 23:15:08
问题 I am using the Xcode 8.0 GM. I created a default single-view app with my deployment target set to 9.0. In my Podfile I'm targeting the bleeding edge Swift 3 branch: source 'https://github.com/CocoaPods/Specs.git' platform :ios, '9.0' use_frameworks! target 'MyProject' do pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :branch => 'swift3' end I run pod install and get ... Installing Alamofire (4.0.0-beta.2) ... fantastic, no problems. I open MyProject.xcworkspace . This

post application/x-www-form-urlencoded Alamofire

为君一笑 提交于 2019-12-08 15:47:18
问题 I want to use Alamofire to retrieve a bearer token from Web API but I am new to ios and alamofire. How can I accomplish this with Alamofire? func executeURLEncodedRequest(url: URL, model: [String : String]?, handler: RequestHandlerProtocol) { addAuthorizationHeader() Alamofire.request(.POST,createUrl(url), parameters: model, headers: headers,encoding:.Json) } 回答1: Well you don't really need Alamofire to do this (it can be simply done using a plain NSURLRequest ) but here goes: let headers = [

Alamofire Request error: NSURLErrorDomain Code -1005 The network connection was lost

非 Y 不嫁゛ 提交于 2019-12-08 15:45:30
问题 I'm working on transferring my project from AFNetworking to Alamofire. Really like the project. However, I'm receiving this error when attempting to make a GET request. Here's some example code: class func listCloudCredntials(onlyNew onlyNew: Bool = true, includePending: Bool = true) -> Request { let parameters: [String: AnyObject] = includePending ? ["include_pending": "true"] : [:] let urlString = "https://myapp-staging.herokuapp.com/api/1/credntials" let token = SSKeychain.storedToken()

Alamofire Multipart request

做~自己de王妃 提交于 2019-12-08 14:09:17
问题 I am new to swift programming. i am trying do Multipart request via alamofire .Issue is that one of value in my parameters is array of objects. My Question is how to append array of object to Multipart request. Here are my parameters. let parameters = [ "originguid":"63d6sd5", "signees":[Signess], //Here is issue "signees"is an array of objects "customer":"yes" ] as [String : Any] here is my request Alamofire.upload( .POST, URLString: myUrl, multipartFormData: { multipartFormData in if let