1

I want to get the responseObject. I tried ASI but people offer me to try AFNetworking.But I keep getting error. Where am I doing wrong?With SOAPUI I can get the results. Thank you.

The method in wcf:

ListHastaAra(int kat,int oda,string hastaAdi,int protokolNo,int yatanAyaktan);

the url that I use "http://... /rest /HastaAra" IOS part:

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    NSDictionary *params = @{@"kat": @"0",@"oda": @"0", @"hastaAdi":hastaAdi, @"protokolNo":@"0",@"yatanAyaktan":@"1"};

    [manager POST:HASTAARAIP parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {

        NSLog(@"JSON: %@", responseObject);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"Error: %@", error);
    }];

The error log is:

Error: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (JSON text did not start with array or object and option to allow fragments not set.) UserInfo=0x8c47a30 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}

David Snabel-Caunt
  • 57,804
  • 13
  • 114
  • 132
user3065761
  • 65
  • 1
  • 10
  • The response you are getting back from your API is not the correct format or the JSON content-type is not being set in the header with the response, that is why you are getting an error and no responseObject. – sbarow Dec 05 '13 at 07:49
  • I add manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"application/json"]; but still same error. – user3065761 Dec 05 '13 at 07:58
  • Try the url in http requester and validate response json in http://jsonlint.com/. To set content type add "header('Content-Type: application/json');" to the first line of your php code at server which generate json – arundevma Dec 05 '13 at 08:05
  • The server is wcf. What if I add endpoint informations again to the "manager"? How can I do it? – user3065761 Dec 05 '13 at 08:14
  • Not sure if this will help you, http://stackoverflow.com/questions/2086666/how-do-i-return-clean-json-from-a-wcf-service – sbarow Dec 05 '13 at 08:22
  • Your server is not responding with valid JSON – David Snabel-Caunt Dec 05 '13 at 10:48

0 Answers0