我的代码:
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。关于导致错误的任何想法?
谢谢!!