我正在尝试使用 AFNetworking 发布到 URL,无论我做什么,我都会不断收到错误消息:
Error Code: -1011 - Expected status code in (200-299), got 404
我的代码如下:
NSString *baseurl = @"http://mysiteurl";
NSString *path = @"/user/register/";
AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:baseurl]];
[client registerHTTPOperationClass:[AFJSONRequestOperation class]];
//[client setAuthorizationHeaderWithUsername:@"myusername" password:@"mypassword"];
[client postPath:path parameters:[NSDictionary dictionaryWithObjectsAndKeys:_userName,@"user", _email, @"email",_password,@"password", nil] success:^(AFHTTPRequestOperation *operation, id JSON) {
//NSLog(@"sjson: %@", [JSON valueForKeyPath:@"entries"]);
NSLog(@"sjson: %@", JSON);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error Code: %i - %@",[error code], [error localizedDescription]);
}];
当我直接去时,http://mysiteurl/user/register/
我可以看到 JSON。
我究竟做错了什么?