2015-05-28 53 views
1

我試圖發送POST請求到服務器AFNetworking 2.0可可錯誤3840

NSDictionary * dict = @{@"credentials": @{ 
           @"name": @"Valod", 
           @"password": @"test" 
           } 
         }; 

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; 
manager.responseSerializer = [AFJSONResponseSerializer serializerWithReadingOptions:NSJSONReadingAllowFragments]; 

[manager POST:URL parameters:dict success:^(AFHTTPRequestOperation *operation, id responseObject) { 
    NSLog(@"JSON: %@", responseObject); 
} failure:^(AFHTTPRequestOperation *operation, NSError *error) { 
    NSLog(@"Error: %@", error); 
}];` 

,但我得到的錯誤

錯誤域= NSCocoaErrorDomain代碼= 3840「的操作不能(可可錯誤3840.)「(字符0附近的值無效)UserInfo = 0x7fd6214a5d70 {NSDebugDescription =字符0周圍的值無效,NSUnderlyingError = 0x7fd62150ec60」請求失敗:內部服務器錯誤(500)「}

我測試與谷歌的API調用application.And響應JSON是有效的JSON

+0

可能重複[可可錯誤3840使用JSON(IOS)(http://stackoverflow.com/questions/14171111/cocoa-error-3840-using-json-ios) – Eimantas

+0

我看到這個帖子但它不能幫助我 –

回答

0

檢查requestSerializer,也許這是AFHTTPRequestSerializer代替AFJSONRequestSerializer。 嘗試設置manager.requestSerializer = [AFJSONRequestSerializer serializer];

相關問題