AFNetworking3.x Error Code:3840
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.}
解決辦法:
- 設定請求管理者,因為傳遞過去和接收回來的資料都不是json型別的,所以在這裡要設定為AFHTTPRequestSerializer和AFHTTPResponseSerializer
manager.requestSerializer = [AFHTTPRequestSerializer serializer];// 請求
manager.responseSerializer = [AFHTTPResponseSerializer serializer];// 響應
- 在success中將responseObject轉換為一個字串
//轉碼
NSString *string = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
- 整體程式碼如下:
///AFNetworking 3.x
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
manager.requestSerializer = [AFHTTPRequestSerializer serializer];// 請求
manager.responseSerializer = [AFHTTPResponseSerializer serializer];// 響應
[manager POST:urlString parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject) {
//轉碼
NSString *string = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
NSLog(@"JSON: %@", string);
} failure:^(NSURLSessionTask *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
相關文章
- 【ERROR】OPatch failed with error code 73ErrorAI
- perror error codeError
- System Error CodesError
- OPatch failed with error code 73AIError
- Windows Update error codesWindowsError
- Oracle XA Exception error codeOracleExceptionError
- Error in Memento Sample Code?Error
- Error Domain=kAFAssistantErrorDomain Code=7ErrorAI
- Mysql-error code彙總MySqlError
- Troubleshooting POST error codesError
- [ERROR] Slave I/O: Replication event checksum Error_code: 1743Error
- 【故障處理】Bug : ASM FAILS WITH CHECKRESOURCE ERROR ERROR CODE = 139ASMAIError
- Error_code: 2003Error
- ORA-00600: internal error codeError
- MySQL報錯 Error_code: 1045MySqlError
- ORA-00600internal error code argumentsError
- CUSTOMER INTERFACE STATUS ERROR CODESError
- ORA-00610: Internal error codeError
- An error occurred while the wizard was checking the current Windows product license. Error Code: 8:ErrorWhileWindows
- error code 0x534. [SQLSTATE 42000] (Error 15404)).ErrorSQL
- 執行flutter run命令報錯::ERROR: Could not connect to lockdownd, error code -17FlutterError
- Sub-process /usr/bin/dpkg returned an error codeError
- weblogic報錯: OPatch failed with error code 73WebAIError
- ORA-00600: internal error code, arguments: [kpnatdm】Error
- OPatch failed with error code 73(OracleHomeInventory gets null oracleHomeInfo)AIErrorOracleNull
- Sublime Text: [Decode error - output not utf-8]Error
- ORA-00600: internal error code, arguments: [525]Error
- "OPatch failed with error code 73"故障一例AIError
- [Code Composer Studio] fatal error #6001Error
- OGG-00519 Fatal error executing DDL replication: [Error code [1435]Error
- Composer 提示 zlib_decode (): data errorError
- ORA-00600: internal error code, arguments: [4194]Error
- sublime 出現 [Decode error - output not utf-8]Error
- OPatch failed with error code 73 (These not-installed components)AIError
- ORA-00600: internal error code, arguments: [15753]Error
- oem12c opatchauto failed with error code 135AIError
- mysql_slave :Error_code: 1593解決MySqlError
- SCSI error : return code = 0x10000Error