title: Making HTTP Request with header in Swift
body: <p>I am trying to make an HTTP request to the Imgur API. I am trying to retrieve all images associated with the tag "cats." The url, according to the Imgur API is: <a href="https://api.imgur.com/3/gallery/t/cats" rel="noreferrer">https://api.imgur.com/3/gallery/t/cats</a></p>
  
  <p>the Imgur API states the following about the authorization needed to make get requests:</p>
  
  <blockquote>
    <p>For public read-only and anonymous resources, such as getting image 
    info, looking up user comments, etc. all you need to do is send an 
    authorization header with your <code>client_id</code> in your requests. This also 
    works if you'd like to upload images anonymously (without the image<br>
    being tied to an account), or if you'd like to create an anonymous<br>
    album. This lets us know which application is accessing the API. </p>
  
  <pre><code>Authorization: Client-ID YOUR_CLIENT_ID
  </code></pre>
  </blockquote>
  
  <p>I've looked at the following questions and tried things suggested there, but none of them have helped.</p>
  
  <p><a href="https://stackoverflow.com/questions/27956943/json-nsurlrequest-with-credentials?lq=1">JSON NSURLRequest with credentials</a></p>
  
  <p><a href="https://stackoverflow.com/questions/27723912/swift-get-request-with-parameters">Swift GET request with parameters</a></p>
  
  <p><a href="https://stackoverflow.com/questions/27814050/how-to-make-a-http-get-and-set-httpheader-in-swift">How to make a Http get and set httpHeader in Swift?</a></p>
  
  <p>My current code is this:</p>
  
  <pre><code>let string = "https://api.imgur.com/3/gallery/t/cats"
  let url = NSURL(string: string)
  let request = NSMutableURLRequest(URL: url!)
  request.setValue("clientIDhere", forHTTPHeaderField: "Authorization")
  //request.addValue("clientIDhere", forHTTPHeaderField: "Authorization")
  request.HTTPMethod = "GET"
  let session = NSURLSession.sharedSession()
  
  let tache = session.dataTaskWithRequest(request) { (data, response, error) -&gt; Void in
      if let antwort = response as? NSHTTPURLResponse {
          let code = antwort.statusCode
          print(code)
      }
  }
  tache.resume()
  </code></pre>
  
  <p>But I continually get a status code of 403, meaning authorization is required. What am I doing wrong?</p>