title: Microsoft Outlook API and Swift
body: <p>How to access a microsoft outlook API using swift. I want to use the microsoft outlook api to allow a user to search for people in a certain outlook server. the search framework is already set up. I am just really confused with how to even access the server. The code is mostly from consulting people who have done this before. This is the code that I have so far: </p>
  
  <pre><code>class ExchangeAPI {
  
  func HTTPsendRequest(request: NSMutableURLRequest, callback: (String, String?) -&gt; Void) {
      //implementing core data
  
      var appDel: AppDelegate = (UIApplication.sharedApplication().delegate as! AppDelegate)
      var context: NSManagedObjectContext = appDel.managedObjectContext!
      let ent = NSEntityDescription.entityForName("Emails", inManagedObjectContext: context)
  
      var email = Emails(entity: ent! , insertIntoManagedObjectContext: context)
  
          let task = NSURLSession.sharedSession().dataTaskWithRequest(
              request,
              completionHandler: {
                  data, response, error in
                  if error != nil {
                      callback("", error!.localizedDescription)
                  } else {
                      callback(
                          NSString(data: data!, encoding: NSUTF8StringEncoding)! as String,
                          nil
                      )
                  }
          })
  
          task.resume()
      }
  
  
  
   func HTTPGet(url: String, callback: (String, String?) -&gt; Void) {
  //implementing core data
  var appDel: AppDelegate = (UIApplication.sharedApplication().delegate as! AppDelegate)
  var context: NSManagedObjectContext = appDel.managedObjectContext!
  let ent = NSEntityDescription.entityForName("Emails",inManagedObjectContext: context)
  
  var email = Emails(entity: ent! , insertIntoManagedObjectContext: context)
  
      var request = NSMutableURLRequest(URL: NSURL(string: url)!)
      HTTPsendRequest(request, callback: callback)
          request.URL = NSURL(string: "https://mail.SAP.com/EWS/Exchange.asmx")
          request.HTTPMethod = "GET"
  
  }
  
  
  
  
   }
  </code></pre>