Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSString *roomnumber = (NSString *)[newPatient objectForKey:@"roomNumber"];
- NSString *urlString = [NSString stringWithFormat:@"http//norkelton.com/room/%d",roomnumber];
- // NSString *encodedString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
- NSURL *theURL = [NSURL URLWithString:urlString];
- //request
- NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:theURL];// cachePolicy:
- [theRequest setHTTPMethod:@"POST"];
- [theRequest setHTTPShouldHandleCookies:YES];
- //cookies
- NSDictionary * headers = [NSHTTPCookie requestHeaderFieldsWithCookies:[[Cookies sharedCookies] cookies]];
- [theRequest setAllHTTPHeaderFields:headers];
- //body of request
- NSString *bodyString = newPatient.JSONRepresentation;
- NSData *bodyData = [bodyString dataUsingEncoding:NSUTF8StringEncoding];
- [theRequest setHTTPBody:bodyData];
- NSHTTPURLResponse *response;
- //NSError *theError = NULL;
- NSData *theResponseData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response error:nil];
- NSLog(@"status code: %d\n",[response statusCode]);
- NSLog(@"RESPONSE HEADERS: \n%@", [response allHeaderFields]);
- NSString *theResponseString = [[[NSString alloc] initWithData:theResponseData encoding:NSUTF8StringEncoding] autorelease];
- NSLog(@"******************************------------------%@\n",theResponseString);
Add Comment
Please, Sign In to add comment