我正在尝试创建POST请求。我正在创建一个自定义URL但是当我尝试打印出值时,我会收到以下错误:
编辑:
(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 *'
这是我的代码:
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]];
我错过了什么?