Questions tagged [alamofire]

Alamofire is an HTTP networking library written in Swift.

Alamofire is an HTTP networking library written in Swift.

Features

  • Chainable Request / Response Methods
  • URL / JSON / plist Parameter Encoding
  • Upload File / Data / Stream / MultipartFormData
  • Download File using Request or Resume Data
  • Authentication with URLCredential
  • HTTP Response Validation
  • Upload and Download Progress Closures with Progress
  • cURL Command Output
  • Dynamically Adapt and Retry Requests
  • TLS Certificate and Public Key Pinning
  • Network Reachability
  • Comprehensive Unit and Integration Test Coverage

Project

6065 questions
75
votes
11 answers

'Method' is ambiguous for type lookup in this context, Error in Alamofire

I am using Alamofire for network handling in swift and run into one weird error. It seems like we can't pass Method enum as parameter. [Error is on Method parameter] private func apiRequest(method: Method, url: String, apiData: [String :…
Ravi Prakash
  • 1,078
  • 1
  • 8
  • 14
73
votes
14 answers

Send POST parameters with MultipartFormData using Alamofire, in iOS Swift

I am using Alamofire, very first time. I am using the latest version Alamofire 1.3.1. I want to send one image , one video and some POST parameters in one API call. I am using multipart form data. The mutipart module is working. I am facing a…
Ankush
  • 2,405
  • 3
  • 22
  • 45
73
votes
1 answer

NSURLSession concurrent requests with Alamofire

I'm experiencing some strange behaviour with my test app. I've about 50 simultaneous GET requests that I send to the same server. The server is an embedded server on a small piece of hardware with very limited resources. In order to optimize the…
Hannes
  • 3,752
  • 2
  • 37
  • 47
70
votes
11 answers

how to use Alamofire with custom headers

I am just starting to take a look at Mattt's wonderful new Alamofire swift networking library and am not quite sure how one would use it with custom headers. The code i am trying to convert from AFNetworking to Alamofire is this: let request =…
Reneli
  • 1,756
  • 2
  • 16
  • 26
68
votes
9 answers

Sending json array via Alamofire

I wonder if it's possible to directly send an array (not wrapped in a dictionary) in a POST request. Apparently the parameters parameter should get a map of: [String: AnyObject]? But I want to be able to send the following example json: [ …
fruechtemuesli
  • 2,809
  • 3
  • 17
  • 15
67
votes
16 answers

Set timeout in Alamofire

I am using Alamofire 4.0.1 and I want to set a timeout for my request. I tried the solutions gived in this question: In the first case, it throws a NSURLErrorDomain (timeout is set correctly): let configuration =…
ƒernando Valle
  • 3,634
  • 6
  • 36
  • 58
63
votes
5 answers

How to return value from Alamofire

I am making url calls thru an API that I created using swift as follows: class API { let apiEndPoint = "endpoint" let apiUrl:String! let consumerKey:String! let consumerSecret:String! var returnData = [:] init(){ self.apiUrl =…
u54r
  • 1,767
  • 2
  • 15
  • 26
62
votes
3 answers

What are Embedded Binaries in Xcode?

I'm using Alamofire in a Swift project, and part of their manual installation instructions are to add Alamofire under Embedded Binaries in the General tab for my application target. What are Embedded Binaries?
Doug Richardson
  • 10,483
  • 6
  • 51
  • 77
62
votes
3 answers

Synchronizing remote JSON data to local cache storage in iOS Swift

I am trying to find the solution for simple processing all necessary steps for read-only consuming remote JSON data on iOS devices. It means fetching remote JSON data, store to local cache on iOS device for offline usage, refresh the cache, parsing…
kolisko
  • 1,548
  • 3
  • 17
  • 22
57
votes
2 answers

Any way to get the response body during HTTP errors?

I'm hitting an API that will occasionally throw a HTTP 403 error, and the response body can give some extra information in the form of json, however for the life of me I can't seem to get the information back out from the Alamofire response objects.…
Kevin DiTraglia
  • 25,746
  • 19
  • 92
  • 138
54
votes
15 answers

Extra argument 'method' in call

Getting error while calling Alamofire request method in the latest version(4.0.0). The syntax is: Alamofire.request(urlString,method: .post, parameters: requestParams, encoding: .JSON, headers: [:]) the type of requestParam is [String:Any]
CMA
  • 1,528
  • 1
  • 11
  • 22
54
votes
14 answers

Alamofire Swift 3.0 Extra argument in call

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 +…
Agreensh
  • 1,305
  • 1
  • 12
  • 15
54
votes
9 answers

How to disable caching in Alamofire

When I send a GET request twice with Alamofire I get the same response but I'm expecting a different one. I was wondering if it was because of the cache, and if so I'd like to know how to disable it.
Rémi Telenczak
  • 690
  • 1
  • 5
  • 9
53
votes
7 answers

Chain multiple Alamofire requests

I'm looking for a good pattern with which I can chain multiple HTTP requests. I want to use Swift, and preferrably Alamofire. Say, for example, I want to do the following: Make a PUT request Make a GET request Reload table with data It seems that…
jlhonora
  • 10,179
  • 10
  • 46
  • 70
50
votes
5 answers

Swift Alamofire VS AFNetworking

I am developing an app using Swift. I want to call a REST API. I found there are two popular libraries, AFNetworking and Alamofire. But I don't know which is better (is more popular or has more features). Can anybody suggest what are the main…
Puvanarajan
  • 2,786
  • 6
  • 26
  • 37