我的代码: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