2016-09-02 193 views
0

我遇到了這個問題2天,Android應用程序可以很好地使用這個後臺界面,但我總是收到500錯誤。我的代碼是這樣的。代碼= -1011「請求失敗:內部服務器錯誤(500)

AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; 
manager.requestSerializer = [AFJSONRequestSerializer serializer]; 
manager.responseSerializer = [AFHTTPResponseSerializer serializer]; 
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"]; 
[manager POST:urlString parameters:self.param.mj_keyValues success:^(NSURLSessionDataTask *task, id responseObject) { 
     ....  
} failure:^(NSURLSessionDataTask *task, NSError *error) { 
     .... 
}]; 

,然後,該程序進入故障塊,我也得到NSError登錄這個樣子。

Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: internal server error (500)" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7fc26b49a080> { URL: https://training.duapp.com/record_data } { status code: 500, headers { 
Server = openresty; 
Content-Type = text/html;charset=utf-8; 
Vary = Accept-Encoding; 
Content-Language = en; 
Date = Fri, 02 Sep 2016 03:55:00 GMT; 
Content-Encoding = gzip; 
Content-Length = 646; 
Connection = keep-alive; 
} 
}, NSErrorFailingURLKey=https://training.duapp.com/record_data, com.alamofire.serialization.response.error.data= 

然後我試圖修女從NSDictionary中到的NSData或NSString的帕拉姆,並改變requestSerializer它,但全部失敗,錯誤500.該參數的格式沒有錯誤,這與我的b一致ackground workmate.Can I can help you from you?我該怎麼辦?

+0

可以yiu顯示一些額外的代碼 –

回答

1

Code=-1011 "Request failed: internal server error (500)"是服務器端問題。請檢查您的服務器組以檢查,因爲服務器正在向您的請求返回錯誤。

+0

感謝您的關注,與我的團隊溝通後,我成功解決了這個問題。 – HuangLW

+0

HuangLW歡迎您.. :) – Manish

0
NSMutableDictionary * params = [[NSMutableDictionary alloc] init]; 
[params setObject:@"214" forKey:@"id"]; 
NSURL *baseURL = [NSURL URLWithString:@"http://example.com/api_url"]; 
NSString *path = @"Path"; 
AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] initWithBaseURL:baseURL]; 
manager.requestSerializer = [AFJSONRequestSerializer serializer]; 
manager.responseSerializer = [AFHTTPResponseSerializer serializer]; 
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"]; 
[manager GET:path parameters:params success:^(NSURLSessionDataTask *task, id responseObject){ 
     NSDictionary *json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil]; 
     NSLog(@"Success: %@", json); 
    }failure:^(NSURLSessionDataTask *task, NSError *error){ 
      NSLog(@"Failure: %@", error); 
    }]; 
相關問題