0

i am unable to find solution of NSCocoaErrorDomain Code=3840 error in afnetworking 2.0

this is code i used

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer.acceptableContentTypes = [manager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];

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

         NSLog(@"JSON: %@", responseObject);

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

this is the error getting

Error: Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}
Sport
  • 8,570
  • 6
  • 46
  • 65

1 Answers1

0

Try to use AFHTTPResponseSerializer instead

manager.responseSerializer = [AFHTTPResponseSerializer serializer];

Because you're using acceptableContentType of @"text/html", I assume you don't need a JSON serializer on response call. So this should be fine for your case.

haik.ampardjian
  • 864
  • 8
  • 20