title: Post request in iOS?
body: <p>I'm trying to do a POST request in my iOS application.</p>
  
  <p>The following line works as intended in command line of my Mac</p>
  
  <pre><code>curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"email":"frank.smith@gmail.com","password":"frankSmith"}' http://server.address
  </code></pre>
  
  <p>However, I can't seem to convert it properly to iOS.  Here is what I've tried:</p>
  
  <pre><code>NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",SERVER_ADDRESS]];
  NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
  NSString *messageBody = [NSString stringWithFormat:@"{\"email\":\"%@\",\"password\":\"%@\"}",@"frank.smith@gmail.com",@"frankSmith"];
  [request setHTTPMethod:@"POST"];
  [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
  [request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
  [request setHTTPBody:[messageBody dataUsingEncoding:NSUTF8StringEncoding]];
  
  NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request
                                                                delegate:self];
  [connection start];
  </code></pre>
  
  <p>What am I missing/doing wrong?</p>