Error Domain=com.alamofire.error.serialization.response Code=-1011 “Request failed: internal server error (500)”

断了今生、忘了曾经 提交于 2020-01-13 09:39:10

问题


I am using afnetworking in my application.

To post data on server I wrote following code

- (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

    }];
}

But in response I got following error

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),

I don't understand where I made mitake. Any help would be appriciable.


回答1:


I think you're ok. Your server returns an error to your request. Code 500 usually means internal error such as unhandled exception. So it definitely has nothing to do with client.



来源:https://stackoverflow.com/questions/26231780/error-domain-com-alamofire-error-serialization-response-code-1011-request-fail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!