0
我有奇怪的問題與AFHTTPClient,我發送POST請求喜歡AFHTTPClient預期的狀態碼(200-299),有409
NSURL *u = [NSURL URLWithString:HTTP_SERVER];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL: u];
[httpClient setParameterEncoding:AFJSONParameterEncoding];
[httpClient postPath:REGISTER
parameters:params
success:^(AFHTTPRequestOperation *operation, id JSON) {
int statusCode = [operation.response statusCode];
if(statusCode == 201){
[self performSegueWithIdentifier:@"register" sender:self];
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"[HTTPClient Error]: %@", error.localizedDescription);
}];
和服務器工作正常(在某些情況下,服務器需要回答我代碼409,API是以這種方式製作的),但是我在XCode中出現錯誤,如Expected status code in (200-299), got 409
如何解決此問題(我的手綁定了,我無法更改API和錯誤代碼)?
[error userInfo]會給你更多關於錯誤的信息。 – Inoka 2013-02-18 10:30:06