title: .NET Web Api Token Authentication Rest Service "Get" Method in Objective-C
body: <p>I'm trying to access the following URL: 
  <a href="http://appointmentreminder4.azurewebsites.net/Profile" rel="nofollow">http://appointmentreminder4.azurewebsites.net/Profile</a></p>
  
  <p>This URL uses a "Get" method, and is supposed to provide JSON results. Before accessing the URL, you need to login using your Email Address and Password. After logging in successfully, the Web API issues a token. This token is used in ALL communications going forward.</p>
  
  <p>I am currently unable to retrieve the token in Objective-C. I have attempted to google this problem, but I cannot figure out: </p>
  
  <p>1) How to get the token</p>
  
  <p>2) How to get the JSON output from the URL.</p>
  
  <p>Here is the code I have written so far that returns neither the JSON, nor the token:</p>
  
  <pre><code>    NSDictionary *postDict = [[NSDictionary alloc] initWithObjectsAndKeys:
                                @"Email Adress", @"MyEmailAddress",
                                @"Password", @"MyPassword",
                                nil];
  
      NSError *error = nil;
      NSData* jsonData = [NSJSONSerialization dataWithJSONObject:postDict options:kNilOptions error:&amp;error];
      NSURLResponse *response;
      NSData *localData = nil;
  
      NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://appointmentreminder4.azurewebsites.net/home"]];
      [request setHTTPMethod:@"POST"];
  
      if (error == nil)
      {
          [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
          [request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
          [request setHTTPBody:jsonData];
  
          // Send the request and get the response
          localData = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;response error:&amp;error];
  
          NSString *result = [[NSString alloc] initWithData:localData encoding:NSASCIIStringEncoding];
          NSLog(@"Post result : %@", result);
      }
  </code></pre>
  
  <p>If the above link fails, use this link to navigate to the specific page:</p>
  
  <p><a href="http://appointmentreminder4.azurewebsites.net/home" rel="nofollow">http://appointmentreminder4.azurewebsites.net/home</a></p>