我的代碼:AFNetworking錯誤:「預期狀態碼(200-299),獲得404」
NSURL *url = [NSURL URLWithString:@"http:testurl.com"];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
NSString *email = @"[email protected]";
NSString *password = @"test";
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
email, @"email",
password, @"password",
nil];
[httpClient postPath:@"/myobject" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:AFJSONParameterEncoding];
NSLog(@"Request Successful, response '%@'", responseStr);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"[HTTPClient Error]: %@", error.localizedDescription);
}];
即使我知道服務器是預期POST我試圖獲取和放置過,仍然收到同樣的錯誤。我也檢查了100次URL。任何想法是什麼導致了錯誤?
謝謝!
那樣簡單的建議是,是我需要什麼謝謝! – markw 2013-02-23 13:40:01