我正在使用AFNetworking
最新版本查询我的服务器。
我的服务器端 PHP 正在发送与 PHP 相关的错误,但我无法看到错误是什么(因此我可以调试它),因为 AFNetworking 需要 JSON。
谁能告诉我如何才能看到完整的 HTTP 结果。我已经研究过,我知道这与我当前块没有的/块operation.responseString
内部有关,我无法以某种方式将它添加为另一个块变量。success
fail
AFHTTPRequestOperation* operation
我真的很感激一些帮助。
以下代码使用
NSURL *url = [[NSURL alloc]initWithString:URL];
AFHTTPClient *httpClient = [[AFHTTPClient alloc]initWithBaseURL:url];
NSURLRequest *request = [httpClient multipartFormRequestWithMethod:@"POST" path:URLPATH parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> formData)
{
//...
}
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON){
NSLog(@"Inside the success block %@",JSON);
[[self delegate ]shareExerciseDone:JSON];
[[self delegate] activityIndicatorFinish];
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON){
NSLog(@"Response text is: %@", operation.responseString);
NSLog(@"json text is: %@", JSON);
NSLog(@"Request failed with error: %@, %@", error, error.userInfo);
[[self delegate] activityIndicatorFinish];
}];
[operation start];
错误
Request failed with 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=0xc1b4520 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}, {
NSDebugDescription = "JSON text did not start with array or object and option to allow fragments not set.";