简体   繁体   中英

Domain=NSCocoaErrorDomain Code=3840 error in afnetworking 2.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.}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM