- (IBAction)tapSaveTodo:(id)sender { NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL: [NSURL URLWithString:kAddUrl] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; [theRequest setHTTPMethod:@"POST"]; [theRequest addValue:@"application/json" forHTTPHeaderField:@"ACCEPT"]; [theRequest addValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [theRequest addValue:kMobileServiceAppId forHTTPHeaderField:@"X-ZUMO-APPLICATION"]; NSData *data = nil; NSString *imageData = nil; if (imageViewNewTodo.image != nil) { UIImage *image = imageViewNewTodo.image; data = UIImagePNGRepresentation(image); imageData = [data base64EncodedString]; } //build an info object and convert to json NSDictionary* jsonDictionary = [NSDictionary dictionaryWithObjectsAndKeys: @"false", @"complete", txtTodoText.text, @"text", imageData, @"coltest", nil]; //convert JSON object to data NSError *error; NSData* jsonData = [NSJSONSerialization dataWithJSONObject:jsonDictionary options:NSJSONWritingPrettyPrinted error:&error]; [theRequest setHTTPBody:jsonData]; // create the connection with the request and start loading the data NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; if (theConnection) { // Create the NSMutableData to hold the received data. // receivedData is an instance variable declared elsewhere. receivedData = [NSMutableData data]; } else { // We should inform the user that the connection failed. } }