【发布时间】:2013-02-23 02:42:06
【问题描述】:
我的代码:
NSURL *url = [NSURL URLWithString:@"http:testurl.com"];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
NSString *email = @"test@test.com";
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,但我也尝试了 GET 和 PUT,但仍然收到相同的错误。我还检查了 100 次 URL。关于导致错误的任何想法?
谢谢!!
【问题讨论】:
标签: iphone ios objective-c rest afnetworking