vendredi 30 janvier 2015

how to fetch data from server through afnetworking in phone sdk

I am creating iOS app and trying to fetch data from server through afnetworking code is following



NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];

NSURL *URL = [NSURL URLWithString:@"http://XXXXXX/DisplayDetail.php"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];
NSURLSessionDataTask *dataTask = [manager dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
if (error) {
NSLog(@"Error: %@", error);
} else {
NSLog(@"%@ %@", response, responseObject);
}
}];
[dataTask resume];


But I am getting following error



Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo=0x7f9f3943aee0 {com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7f9f3954e0b0> { URL: http://ift.tt/1uDW4C6 } { status code: 200, headers {
Connection = "Keep-Alive";
"Content-Type" = "text/html";
Date = "Thu, 29 Jan 2015 07:30:36 GMT";
"Keep-Alive" = "timeout=5";
Server = "Apache/2.4.10 (Unix) OpenSSL/1.0.1e-fips mod_bwlimited/1.4 mod_fcgid/2.3.10-dev";
"Transfer-Encoding" = Identity;
"X-Powered-By" = "PHP/5.4.34";}
},
NSErrorFailingURLKey=http://ift.tt/1uDW4C6, com.alamofire.serialization.response.error.data=<5b7b2275 7365725f 6964223a 22313039 222c2275 7365725f 656d6169 6c223a22 616e7572 61674067


............


So please help me how to resolve it.




Aucun commentaire:

Enregistrer un commentaire