【发布时间】:2013-08-10 14:56:38
【问题描述】:
这是我的代码:
NSURL *url = [NSURL URLWithString:@"http://wspublisherv2.skygiraffe.com/WSpublisherV2.svc/Authenticate"];
AFHTTPClient *client = [[AFHTTPClient alloc]initWithBaseURL:url];
NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys:@"john@sgdemo.com", @"UserName", @"123", @"Password", nil];
NSLog(@"%@", parameters);
[client postPath:nil parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"success: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"failure: %@", error);
}];
它总是触发故障块,我收到“预期状态码在 (200-299),得到 404”消息。
当我通过 Fiddler 尝试时,它可以工作。
【问题讨论】:
-
我知道 404 是什么意思,只是不知道如何让它工作......
-
我会尝试从基本 URL 中删除
Authenticate并将其作为postPath参数移动。Authenticate不是基本 URL 的一部分;它是执行请求的实际页面。 IE。 “wspublisherv2.skygiraffe.com/WSpublisherV2.svc/Authenticate/”不同于“wspublisherv2.skygiraffe.com/WSpublisherV2.svc/Authenticate”。 -
在我的浏览器上打开它,它说“方法不允许”,我认为 URL 可能是错误的
标签: ios afnetworking