0

我正在使用 NSURLConnection 来使用服务,现在我正在切换到 AFNetworking 但遇到了一些奇怪的错误。我的代码 注意:CTPHTTPClient 是 AFHTTPClient 的子类

NSDictionary *parameters =  @{
                              @"email" : @"test@gyc.com",
                              @"confirmPassword" : @"12345",
                              @"userName" : @"mithilesh",
                              @"password" : @"12345",
                              @"termsAndConditionAccepted" : @1,
                              @"dob" : @"1190-03-05"
                              };

[[CTPHTTPClient sharedCTPHTTPClient] postPath:@"signup.json"
                                   parameters:parameters
                                      success: ^(AFHTTPRequestOperation *operation, id JSON){


                                          NSLog(@"Res = %@",JSON);

                                      }
                                      failure:^(AFHTTPRequestOperation *operation, NSError *error){

                                          [CTPUtilities showAlert:[error localizedDescription] delegate:self];
                                      }];

回复

在此处输入图像描述

在上面的响应中,您可以看到红色矩形它包含有效的响应。使用 NSURLConnection 时我得到了正确的结果。

4

1 回答 1

3

问题可能是服务器端发送失败的 HTTP 状态代码。尽管您发送的是正确的有效负载,但您的请求状态应该基于状态代码,而不是有效负载的内容。AFNetworking 为您执行此操作,正如 AFNetworking 错误所说,服务器返回 500。

于 2013-05-26T14:14:55.680 回答