I am unable to get data using this approach, however its working when using other url and i have also tested in postman where i am getting response.
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
// if you want to sent parameters you can use above code
manager.requestSerializer = [AFJSONRequestSerializer serializer];
[manager GET:@"http://192.168.1.156:81/a.php" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"responseObject %@",responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}];
Error:
"Request failed: unacceptable content-type: text/html" UserInfo=0x8a6b000 {NSErrorFailingURLKey=http://192.168.1.156:81/a.php, AFNetworkingOperationFailingURLResponseErrorKey= { URL: http://192.168.1.156:81/a.php } { status code: 200, headers { Connection = "Keep-Alive"; "Content-Type" = "text/html"; Date = "Tue, 20 May 2014 14:49:20 GMT"; "Keep-Alive" = "timeout=5, max=100"; Server = "Apache/2.4.4 (Win64) PHP/5.4.12"; "Transfer-Encoding" = Identity; "X-Powered-By" = "PHP/5.4.12"; } }, NSLocalizedDescription=Request failed: unacceptable content-type: text/html}
NSArray Conversion Error:
Parsing JSON failed: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Invalid escape sequence around character 4677.) UserInfo=0xa82c130 {NSDebugDescription=Invalid escape sequence around character 4677.}
Parse error on line 258: ... "story_title": "today\'s story", -----------------------^ Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
NSError
object in thefailure
block? What does it say? – RobAFJSONRequestSerializer
for aGET
request.GET
requests don't have a body, but rather encode their parameters in the URL. And, besides, you don't have any parameters. – Rob