objective-c - 错误域=com.alamofire.error.serialization.response 代码=-1011 "Request failed: internal server error (500)"

标签 objective-c iphone afnetworking

我在我的应用程序中使用 afnetworking。

为了在服务器上发布数据,我编写了以下代码

- (void) callLoginAPI:(NSDictionary *)dictProfile{
    // 1

    NSDictionary *params = @{@"username":[dictProfile valueForKey:@"name"],
                             @"first_name":[dictProfile valueForKey:@"first_name"],
                             @"last_name":[dictProfile valueForKey:@"last_name"],
                             @"email":[dictProfile valueForKey:@"email"],
                             @"dob":[dictProfile valueForKey:@"birthday"],
                             @"gender":[dictProfile valueForKey:@"gender"],
                             @"location":[[dictProfile valueForKey:@"location"] valueForKey:@"name"],
                             @"timezone":[dictProfile valueForKey:@"timezone"],
                             @"language":@"",
                             @"profile_pic_url":[NSString stringWithFormat:@"http://graph.facebook.com/%@/picture?type=large",[dictProfile valueForKey:@"id"]],
                             @"cover_pic_url":@""
                             };

    NSString* HOST_URL = [NSString stringWithFormat:@"%@login/",BASE_URL];

    AFHTTPRequestOperationManager *operationManager = [AFHTTPRequestOperationManager manager];
    operationManager.requestSerializer = [AFJSONRequestSerializer serializer];

    [operationManager POST:HOST_URL parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject){
        NSLog(@"resp:%@",responseObject);
        // Enter what happens here if successsful.

    }failure:^(AFHTTPRequestOperation *operation, NSError *error){
        NSLog(@"error:%@",error);
        // Enter what happens here if failure happens

    }];
}

但作为回应我得到了以下错误

error:Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: internal server error (500)" UserInfo=0x7cc8bb50 {com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7ca9d4d0> { URL: http://10.1.81.35:8000/api/login/ } { status code: 500, headers {
    "Content-Type" = "text/html";
    Date = "Tue, 07 Oct 2014 08:25:40 GMT";
    Server = "WSGIServer/0.1 Python/2.7.6";
    Vary = Cookie;
    "X-Frame-Options" = SAMEORIGIN;
} }, NSErrorFailingURLKey=http://10.1.81.35:8000/api/login/, NSLocalizedDescription=Request failed: internal server error (500),

我不明白我在哪里做的 mitake。 任何帮助都将不胜感激。

最佳答案

我觉得你还好。您的服务器向您的请求返回错误。代码 500 通常表示内部错误,例如未处理的异常。所以这绝对与客户无关。

关于objective-c - 错误域=com.alamofire.error.serialization.response 代码=-1011 "Request failed: internal server error (500)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26231780/

相关文章:

ios - AFHTTPSessionManager 子类 : Post API with body.

ios - 第二个 Api 调用正在减慢应用程序 ios

ios - 以编程方式滚动 UIScrollView 然后用手动滚动覆盖

iphone - 我怎样才能摆脱这个警告?

iphone - 应用程序再次启动

iphone - 如何下载音频并在iPhone上同时播放?

iphone - TableView 不进入 willDisplayCell

iphone - 如何更改ProgressView边框颜色

ios - AFHTTPClient 将授权 header 字段设置为 "Token token='\75845hjhrtje84539574 8' "但我只想成为里面的 token

ios - AFRESTClient pathForEntity具有嵌套资源?