This code works perfect. Do this for PUT:
- (void)PutMethod:(NSString *)url andPostData:(NSString *)putData {
NSLog(@"%@", url);
NSLog(@"%@", putData);
NSData *putNSData = [putData dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
NSLog(@"NSData : %@",putNSData);
NSString *putLength = [NSString stringWithFormat:@"%lu", (unsigned long)[putData length]];
NSLog(@"%@", putLength);
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:url]];
[request setHTTPMethod:@"PUT"];
[request setValue:putLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:putNSData];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
[connection start];
if (connection) {
putNSData = [[NSMutableData alloc] init];
}
}