title: URLSession & JSONSerialization Swift 3
body: <p>Before you read this, please understand that I'm somewhat a beginner with Swift and I'm trying to learn. I've browse through some sites in hope of getting answer but I either can't find or do it incorrectly.. I've been following this tutorial but this is old and not updated >><a href="http://www.myplacesandme.com/wordpress/swift-app-tutorial-swiftstocks-tuples-switch-singleton-webservices-part-ii/" rel="nofollow noreferrer">Tutorial I followed</a>&lt;&lt;</p>
  
  <p>I also tried to modified some to swift 3 - though I probably didn't do it right.</p>
  
  <p>How do I exactly do the URLSession correctly? I get this error: </p>
  
  <blockquote>
    <p>invalid conversion from throwing function of type'(_, _, _) throws ->
    Void' to non-throwing function type</p>
  </blockquote>
  
  <p>for this line below: </p>
  
  <blockquote>
    <p>let task : URLSessionDataTask = session.dataTask(with: request,
    completionHandler: {data, response, error -> Void in</p>
  </blockquote>
  
  <p>and for the variable "jsonDict" - I get error that I have </p>
  
  <blockquote>
    <p>extra arg 'error' in call.</p>
  </blockquote>
  
  <p>Thanks in advance</p>
  
  <pre><code>var urlString:String = ("http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.quotes where symbol IN "+stringQuotes+"&amp;format=json&amp;env=http://datatables.org/alltables.env").addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)!
  
      var url : URL = URL(string: urlString)!
      var request: URLRequest = URLRequest(url:url)
      let config = URLSessionConfiguration.default
      let session = URLSession(configuration: config)
  
      let task : URLSessionDataTask = session.dataTask(with: request, completionHandler: {data, response, error -&gt; Void in
  
          if((error) != nil) {
              println(error.localizedDescription)
          }
          else {
              var err: NSError?
  
              var jsonDict = try JSONSerialization.JSONObject(with: data, options: JSONSerialization.ReadingOptions.mutableContainers, error: &amp;err) as NSDictionary
              if(err != nil) {
                  println("JSON Error \(err!.localizedDescription)")
              }
              else {
                  var quotes:NSArray = ((jsonDict.objectForKey("query") as NSDictionary).objectForKey("results") as NSDictionary).objectForKey("quote") as NSArray
                  DispatchQueue.main.async(execute: {
                      .default.post(name: Notification.Name(rawValue: kNotificationStocksUpdated), object: nil, userInfo: [kNotificationStocksUpdated:quotes])
                  })
              }
          }
      })
      task.resume()
  }
  </code></pre>