The data couldn't be read because it isn't in the correct format.\"

寵の児 提交于 2019-12-06 03:51:05

Try below code:

AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];

AFJSONRequestSerializer *serializer = [AFJSONRequestSerializer serializer];
[serializer setStringEncoding:NSUTF8StringEncoding];

manager.requestSerializer=serializer;
manager.responseSerializer.acceptableContentTypes= [NSSet setWithObjects:@"text/html",@"application/json", nil];

 [manager POST:reqFormat parameters:dict1 progress:nil success:^(NSURLSessionTask *task, id responseObject)
     {
         //Print response
     } failure:^(NSURLSessionTask *operation, NSError *error) {
         //Print error
     }];

In AFNetworking 3.0 AFHTTPRequestOperationManager is replaced with AFHTTPSessionManager.

Migration Guide

actually this problem occurred mainly two reasons

  1. when your parameters are wrong. means wrong value or missing parameter.
  2. check your URL . sometime it occurred cause of your wrong URL.

i faced same problem two times with same reason.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!