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
18
votes
3 answers

Using retryWhen to update tokens based on http error code

I found this example on How to refresh oauth token using moya and rxswift which I had to alter slightly to get to compile. This code works 80% for my scenario. The problem with it is that it will run for all http errors, and not just 401 errors.…
tskulbru
  • 2,336
  • 1
  • 20
  • 38
18
votes
3 answers

Alamofire not working (Swift/Xcode 8)

I am getting the following errors when trying to import Alamofire into my project (Cocoapods isn't working for me, so I have to manually import it). Anyway, I'm using XCode 8 and Swift 2.3, and I'm getting these errors: Update: I cleaned XCode,…
Michael Lee
  • 303
  • 3
  • 8
18
votes
10 answers

Always get build error : No such module 'Alamofire'

I followed the instruction of Alamofire in github, I created an xcode project named cocoapods-test & I closed it. I go to the project folder run pod init command which generates a Podfile. Then I added the following code to the Podfile: source…
Leem.fin
  • 40,781
  • 83
  • 202
  • 354
18
votes
7 answers

Print Alamofire request body

I'm using Alamofire library for connecting with an API in iOs. I have a problem in one of the connection, and I don't know if it is because of the data encoded in the body or any other thing. In order to detect my error, I'm trying to print in the…
Alfonso
  • 197
  • 1
  • 1
  • 10
17
votes
1 answer

Alamofire 5: Value of type 'Result' has no member 'value'

Is the a new error in Alamofire 5? as this wasn't running into bugs last time. Below are the code which are done. Anyone who used Alamofire facing this? import Foundation import Alamofire class MyAppService { static let shared = MyAppService() let…
L.William
  • 382
  • 1
  • 4
  • 20
17
votes
1 answer

iOS Swift uploading PDF file with Alamofire (Multipart)

I'm currently developing an application using iOS 10 and Swift 3 and Alamofire 4 The purpose of this application is to upload a PDF file generated previously. The PDF generation is working perfectly and the file is created. However the upload…
Napsters Desmars
  • 772
  • 2
  • 7
  • 25
17
votes
4 answers

Upload multiple images in swift using Alamofire

I'm using the following code to upload a single image to a server: private static func urlRequestWithComponents(urlString:String, parameters:Dictionary, imageData:NSData?, imageName: String) -> (URLRequestConvertible , NSData) { …
Arun sharma
  • 642
  • 1
  • 7
  • 17
17
votes
1 answer

Alamofire clear all cookies

I need the user to be able to log out. When they log in now, a cookie gets saved automatically, that works fine. But I want to clear all cookies. NSURLCache.sharedURLCache().removeAllCachedResponses() This does not work
alvarlagerlof
  • 1,516
  • 1
  • 18
  • 27
17
votes
3 answers

How to make a synchronous request using Alamofire?

I am trying to do a synchronous request using Alamofire. I have looked on Stackoverflow and found this question: making an asynchronous alamofire request synchronous. I saw that the accepted answer uses completion to make Alamofire request…
Francisco Romero
  • 12,787
  • 22
  • 92
  • 167
17
votes
7 answers

Swift setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key

I removed manually from my Xcode project Alamofire POD and since this time, I have errors in some UIViewControllers on any UIButton IBOutlet added. I have the following error: Terminating app due to uncaught exception 'NSUnknownKeyException',…
tiamat
  • 879
  • 2
  • 12
  • 35
17
votes
1 answer

Singleton pattern and proper use of Alamofire's URLRequestConvertible

This is a 2 part question the first is similar to this question here: Proper usage of the Alamofire's URLRequestConvertible. But I need a little more help! 1) Do I create an enum router which implements URLRequestConvertible for each model in my…
SnoopyProtocol
  • 911
  • 8
  • 10
17
votes
3 answers

Alamofire loading from cache even when cache policy set to ReloadIgnoringLocalAndRemoteCacheData

I set cache policy to request in Alamofire to ignore local cache. Then I load a viewcontroller with network connection, then I disconnect network connection, kill the app and run it again. Now no network available error is not shown(ie alamofire…
Sai Prasanna
  • 684
  • 1
  • 10
  • 25
16
votes
2 answers

How to send POST request with both parameter and body for JSON data in Swift 3 using Alamofire 4?

Postman api url added below. Present code : let baseUrl = "abc.com/search/" let param = [ "page":"1", "size":"5", "sortBy":"profile_locality" ] let headers = [ "Content-Type": "application/json" ] …
Kushal Shrestha
  • 775
  • 1
  • 10
  • 21
16
votes
3 answers

How to use a Proxy Server with Alamofire 4 and Swift 3

I'm trying to use my Proxy for an API request that needs a specified IP. To debug my issue, I'm requesting the IP from a webservice. This is my current code: import UIKit import Alamofire class ViewController: UIViewController { var…
David Seek
  • 16,783
  • 19
  • 105
  • 136
16
votes
3 answers

Swift "retry" logic on request

So i'm a bit lost on how to implement a retry logic when my upload request fail. Here is my code i would like some guidance on how to do it func startUploading(failure failure: (NSError) -> Void, success: () -> Void, progress: (Double) -> Void) { …
Luis
  • 533
  • 1
  • 6
  • 19