title: URLRequest with headers in Swift
body: <p>Im relatively new to to Swift and I'm having trouble pulling some JSON from an API with the swift native URLRequest - this is in a playground. I've tested the API endpoint and it returns the data just fine in Postman</p>
  
  <p>Here is my code:</p>
  
  <pre><code>//: Playground - noun: a place where people can play
  import Foundation
  import XCPlayground
  import PlaygroundSupport
  import UIKit
  
  let urlString = "http://example.test/industry"
  let session = URLSession.shared
  let url = URL(string: urlString)!
  var request = URLRequest(url: url)
  
  request.addValue("application/json", forHTTPHeaderField: "Content-Type")
  
  session.dataTask(with: request, completionHandler: { (data: Data?, response: URLResponse?, error: Error?) in
      if let responseData = response
      {
          do{
              /*let json = try JSONSerialization.jsonObject(with: responseData, options: [])
               print(json)*/
          }catch{
              print("Could not serialize")
          }
      }
  })
  PlaygroundPage.current.needsIndefiniteExecution = true
  </code></pre>
  
  <p>What am I doing wrong here? I need to send headers to request JSON from my endpoint.</p>