kodeco.com Forums

Alamofire Tutorial: Getting Started

This tutorial shows you how to use Alamofile, an elegant interface built on top of Apple’s Foundation networking stack that simplifies a number of common networking tasks, such as requesting data from RESTful APIs and file upload.

This is a companion discussion topic for the original entry at https://www.raywenderlich.com/774-alamofire-tutorial-getting-started

Even with the enum examples Alamofire is still boilerplate for quite a bit. I came up with a wrapper that I use which really reduces the clutter which you can see at https://www.gargoylesoft.com/blog/alamofire-for-swift-3/

Nice tutorial. Thank you!

1 Like

Great tutorial.

One issue: If someone d/l the starter project, builds on their phone and clicks ‘Take Photo’ it’ll crash due to privacy settings.

Might be a good idea to add the NSCameraUsageDescription string in the app, or at least mention it in the tutorial.

Nice Tutorial.
I want to translate this article into Chinese in my personal blog http://leejunhui.com.
I will identify the original source address,thanks again!

Hey Aaron,

Thanks very much for this tutorial! I’ve held off using third party frameworks as I learned Swift. Really powerful stuff! I just started working with AlamofireImage. Feel like the clouds have finally parted… LOL. Cheers!

1 Like

Hi, I’m getting the following error on the finished project downloaded from the tutorial Alamofire.AFError.ResponseValidationFailureReason.unacceptableStatusCode(401)

I have updated the authorisation token as well, could anyone please let me know what might be the problem?

It was due to wrong authenticationToken. I din’t copy complete token.

Glad you got it! Yeah that token is so weird with the equal signs at the end macOS doesn’t select everything by default.

Hey pixelblur! I thought I had added that to the project. Thanks for the catch!

Hi, I got the following error after we did first upload attempt in tutorial
Error while uploading file: Optional(Alamofire.AFError.responseValidationFailed(Alamofire.AFError.ResponseValidationFailureReason.unacceptableStatusCode(500)))
please, let me know what might be the problem?

Error while uploading file: Optional(Alamofire.AFError.responseValidationFailed(Alamofire.AFError.ResponseValidationFailureReason.unacceptableStatusCode(401)))

If I have the following syntax:

let mutableURLRequest = URLRequest(method: method, urlString: url as! URLRequestConvertible, headers: mutableHeaders)
and my method has this header:

  class func request(method: HTTPMethod, path: String, parameters: [String : Any]?, encoding: ParameterEncoding = URLEncoding.default, headers: [String: String]? = nil) -> Request? {
    let baseURL = NSURL(string: APISettings.baseURL)!
    let url = baseURL.appendingPathComponent(path)

How do I convert url to URLRequestConvertible ?

1 Like

This tutorial is more than six months old so questions regarding it are no longer supported for the moment. We will update it as soon as possible. Thank you! :]

1 Like