HTTPMethod and HTTPBody properties not found on NSMutableURLRequest

292 Views Asked by At

I am trying to create a POST request. I am creating a custom URL but when I try and print out values I get the following errors:

EDIT:

(lldb) po request.HTTPBody
error: property 'HTTPBody' not found on object of type 'NSMutableURLRequest *'

(lldb) po request.HTTPMethod
error: property 'HTTPMethod' not found on object of type 'NSMutableURLRequest *'

Here is my code:

NSString *post = [NSString stringWithFormat:@"&serviceTicket=%@&tags=%@&tags=%@",taskId,fullName,@"test1"];
NSData *postData = [post dataUsingEncoding:NSUTF8StringEncoding];
NSString *postLength = [NSString stringWithFormat:@"%d",[postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:webUrl]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Current-Type"];
[request setHTTPBody:postData];

NSURLConnection *conn = [[NSURLConnection alloc]initWithRequest:request delegate:self];

if(conn)
{
    NSLog(@"Connection Successful");
}
else
{
    NSLog(@"Connection could not be made");
}

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:webUrl]];

What am I missing?

0

There are 0 best solutions below