在发出DELETE请求时,我收到来自服务器的错误请求

时间:2013-01-23 23:20:00

标签: rest httprequest afnetworking

我正在使用AFNetworking共享客户端向REST服务器发出请求。

我的删除代码是:

NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
[[ApiClient sharedClient] deletePath:[NSString stringWithFormat:@"users/%@/venues/%@/", appDelegate.currentUser.userId, venue.venueId] parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSLog(@"venue deleted from saved");
}  failure:^(AFHTTPRequestOperation *operation, NSError *error){
    NSLog(error.description);
}];

当我配置客户端时,我正在添加:

[self registerHTTPOperationClass:[AFJSONRequestOperation class]];    
[self setDefaultHeader:@"Accept" value:@"application/json"];    
[self setDefaultHeader:@"Content-Type" value:@"application/json"];    
[self setParameterEncoding:AFJSONParameterEncoding];

POST请求工作正常,但DELETE请求存在问题。我哪里错了?

1 个答案:

答案 0 :(得分:0)

您需要查看错误并检查出现了什么问题。如果错误没有帮助,那么您将需要使用代理(可能是Charles)并确切了解请求发生了什么以及服务器不喜欢它的原因。

相关问题