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
138
votes
14 answers

How to parse JSON response from Alamofire API in Swift?

Following code I have written and I am getting response in JSON also but the type of JSON is "AnyObject" and I am not able to convert that into Array so that I can use that. Alamofire.request(.POST, "MY URL", parameters:parameters, encoding: .JSON)…
Developer
  • 6,375
  • 12
  • 58
  • 92
128
votes
12 answers

Swift. Could not build objective-c module 'Alamofire'

Fresh vanilla submodule install of Alamofire, using XCode6 and following directions to a T. Something here just isn't fitting right. The error i'm getting is "Could not build objective-c module "alamofire" on import alamofire. Here is a screen shot…
stopshinal
  • 1,891
  • 4
  • 16
  • 24
125
votes
12 answers

Swift Alamofire: How to get the HTTP response status code

I would like to retrieve the HTTP response status code (e.g. 400, 401, 403, 503, etc) for request failures (and ideally for successes too). In this code, I am performing user authentication with HTTP Basic and want to be able to message the user…
GregT
  • 2,194
  • 2
  • 19
  • 15
117
votes
14 answers

How to send a POST request with BODY in swift

I'm trying to make a post request with a body in swift using Alamofire. my json body looks like : { "IdQuiz" : 102, "IdUser" : "iosclient", "User" : "iosclient", "List":[ { "IdQuestion" : 5, "IdProposition":…
Stranger B.
  • 9,004
  • 21
  • 71
  • 108
101
votes
21 answers

Alamofire invalid value around character 0

Alamofire.request(.GET, "url").authenticate(user: "", password: "").responseJSON() { (request, response, json, error) in println(error) println(json) } This is my request with Alamofire, for a certain request it sometime works, but…
Lord Vermillion
  • 5,264
  • 20
  • 69
  • 109
100
votes
11 answers

Uploading file with parameters using Alamofire

I am attempting to upload a file using Alamofire. The upload works fine when using a File (NSUrl), however, I cant seem to figure out how to use the NSData option? This is what I have as a test: var url:NSURL =…
user3432352
  • 1,019
  • 2
  • 8
  • 7
99
votes
12 answers

POST request with a simple string in body with Alamofire

how is it possible to send a POST request with a simple string in the HTTP body with Alamofire in my iOS app? As default Alamofire needs parameters for a request: Alamofire.request(.POST, "http://mywebsite.example/post-request", parameters: ["foo":…
Karl
  • 1,601
  • 3
  • 15
  • 13
95
votes
21 answers

Cocoapods + Cannot load underlying module for 'x'

I am running XCode 7, Swift 2.0, iOS 9. I want to install Alamofire in my project using Cocoapods. I have done the following: gem install cocoapods pod setup pod init Updated Podfile to: # Uncomment this line to define a global platform for your…
user5319603
90
votes
13 answers

IPv6 App Store Rejection

Our update has been rejected twice today for ipv6 network connectivity issues. Our networking code has not changed between the previous release and this current release. The app only makes https network requests to api.metooapp.io, which is…
90
votes
6 answers

Module 'Alamofire' has no member named 'request'

I'm new to iOS Development, I installed Alamofire as said in README, but I have this error as other users and I don't know how to solve it.
user3579107
  • 1,359
  • 2
  • 10
  • 14
82
votes
10 answers

JSONSerialization Invalid type in JSON write (_SwiftValue)

Why does the following code give me the error: Invalid type in JSON write (_SwiftValue). The error is thrown on this line: urlRequest.httpBody = try JSONSerialization.data(withJSONObject: parameters) Full code: let parameters:Parameters =…
jimijon
  • 2,046
  • 1
  • 20
  • 39
80
votes
3 answers

AlamoFire asynchronous completionHandler for JSON request

Having used the AlamoFire framework I've noticed that the completionHandler is run on the main thread. I'm wondering if the code below is a good practice for creating a Core Data import task within the completion handler: Alamofire.request(.GET,…
TheM00s3
  • 3,677
  • 4
  • 31
  • 65
78
votes
6 answers

Proper usage of the Alamofire's URLRequestConvertible

I've read couple tutorials, README from @mattt but can't figure out couple things. What is the proper usage of URLRequestConvertible in real world API? It looks like if I will create one router by implementing URLRequestConvertible protocol for all…
OgreSwamp
  • 4,602
  • 4
  • 33
  • 54
77
votes
10 answers

How can I log each request/response using Alamofire?

Is there a way to log each request / response using Alamofire (something similar to AFNetworkActivityLogger) ? I am aware of Printable, DebugPrintable and Output (cURL) but they are not quite what I am looking for.
Cosmin
  • 2,840
  • 5
  • 32
  • 50
75
votes
22 answers

Failed to load Info.plist from bundle

Cannot run app. Failed to load Info.plist from bundle error occurs. When I CMD+K clean the project, it runs fine. But I have to clean the project every time I make changes and run the app. Following is the screenshot of my podfile:
Chanchal Raj
  • 4,176
  • 4
  • 39
  • 46
1
2 3
99 100