我使用AFNetworking庫使用POST方法來發布服務器上的數據完成。錯誤域= NSCocoaErrorDomain代碼= 3840「的操作不能使用AFNetworking
以下是我的代碼
- (void) callLoginAPI:(NSDictionary *)dictProfile{
// 1
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:[dictProfile valueForKey:@"name"], @"username",
[dictProfile valueForKey:@"first_name"],@"first_name",
[dictProfile valueForKey:@"last_name"],@"last_name",
[dictProfile valueForKey:@"email"],@"email",
[dictProfile valueForKey:@"birthday"],@"dob",
[dictProfile valueForKey:@"gender"],@"gender",
[[dictProfile valueForKey:@"location"] valueForKey:@"name"],@"location",
[dictProfile valueForKey:@"timezone"],@"timezone",
@"",@"language",
[NSString stringWithFormat:@"http://graph.facebook.com/%@/picture?type=large",[dictProfile valueForKey:@"id"]],@"profile_pic_url",
@"",@"cover_pic_url",nil];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
[manager POST:@"http://10.1.81.35:8000/api/login/" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", 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=0x797f2620 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}
我不明白什麼是代碼中的問題下面的錯誤。
生活保護隊友,感謝 – cesarferreira 2014-12-16 12:05:29
它不是爲我工作 – 2015-03-18 09:27:40
不是爲我工作了。 – 2016-09-22 11:13:36