我正在发送JSON数据作为请求,作为响应,我得到0字节的数据,内容类型为“application / JSON; charset = ISO-8859-1”。为什么我没有得到回应?我认为它与编码有关。请帮忙。
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/%@", [self getBaseURL], @"FileListIOS"]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setValue:@"application/json" forHTTPHeaderField:@"content-type"];
[request setHTTPMethod:@"POST"];
UserProfile *userProfile = [[AppCacheManager manager] getUserProfile];
NSString *personalPath = userProfile.personalPath;
NSDictionary *dict = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:userProfile.personalPath,userProfile.personalPath,userProfile.userType, nil] forKeys:[NSArray arrayWithObjects:@"currentpath",@"rootpath",@"usertype", nil]];
NSError *error = nil;
NSData *data = [NSJSONSerialization dataWithJSONObject:dict options:kNilOptions error:&error];
NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
[request setHTTPBody:data];
[NSURLConnection sendAsynchronousRequest:request queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
if(data) {
}
}];