title: NSErrorFailingURLStringKey (kCFErrorDomainCFNetwork error -1017) for specific requests
body: <p>I wrote a helper class with which I make all my requests to a server (Rails 4.1). Most of the requests within this helper class work just fine, but one specific request is failing all the time. I'm using Alamofire for my requests.</p>
  
  <p>Here's some of the code from my helper class:</p>
  
  <pre><code>let responseHandler = { (request: NSURLRequest, response: NSHTTPURLResponse?, object: AnyObject?, error: NSError?) -&gt; Void in
      println("request: \(request) || response: \(response) || object: \(object) || error: \(error)")
  }
  
  // make custom request
  let request = NSMutableURLRequest(URL: NSURL(string: fullPath)!)
  request.HTTPBody = NSJSONSerialization.dataWithJSONObject(["session_key": "ABC"], options: nil, error: nil)
  request.HTTPMethod = "GET"
  request.allHTTPHeaderFields = ["Accept": "application/json", "Content-Type": "application/json"]
  
  Alamofire.request(request).response(responseHandler)
  </code></pre>
  
  <p>Here's the output from the <code>println</code> line in the above code:</p>
  
  <pre><code>request: &lt;NSMutableURLRequest: 0x1702007e0&gt; { URL: http:/wolverine.movie-assistor.staging.c66.me/user } || response: nil || object: Optional(&lt;&gt;) || error: Optional(Error Domain=NSURLErrorDomain Code=-1017 "The operation couldn’t be completed. (NSURLErrorDomain error -1017.)" UserInfo=0x1702ea780 {NSErrorFailingURLStringKey=http://wolverine.movie-assistor.staging.c66.me/user, NSErrorFailingURLKey=http://wolverine.movie-assistor.staging.c66.me/user, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-1, NSUnderlyingError=0x174240240 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1017.)"})
  </code></pre>
  
  <p>I tried resetting Simulator (since I read somewhere it might be a Simulator issue) and tried on my iPhone 6 – but the problem still stays the same. Trying the same URL with the <code>CocoaRESTClient</code> worked fine, so I doubt it's an issue on the server side (leaves to the expected response <code>{"session_key" : "missing"}</code>).</p>
  
  <p>Anyone know what the issue is?</p>
  
  <p><strong>EDIT #1:</strong></p>
  
  <p>The server side which runs on Rails 4.1 looks as follows (<code>application_controller.rb</code>):</p>
  
  <pre><code>prepend_before_action :authenticate_session
  
  def authenticate_session
    if (session_key = params[:session_key]).nil?
      forbidden(session_key: "missing")
    elsif (session = Session.find_by(session_key: session_key)).nil?
      forbidden(session_key: "unknown key")
    elsif session.open != true
      forbidden(session_key: "session closed")
    end
  end
  
  def forbidden(object = {})
    render json: make_hash(object), status: :forbidden
  end
  
  def make_hash(object)
    if object.is_a?(ActiveRecord::Base)
      return object.as_json
    end
  
    return object
  end
  </code></pre>
  
  <p><strong>EDIT #2:</strong></p>
  
  <p>In the mean time I tried different requests and it turns out that the same code on the server side works for all request types except for "GET" requests (I tried POST, PUT and DELETE specifically). So maybe the HTTP body must be different for GET requests?</p>