【问题标题】:I am getting bad request from the server when making DELETE request发出 DELETE 请求时,我收到来自服务器的错误请求
【发布时间】:2013-01-23 23:19:59
【问题描述】:

我正在使用 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 请求出现问题。我哪里错了?

【问题讨论】:

    标签: rest httprequest afnetworking


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2021-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-23
      • 2020-01-13
      • 1970-01-01
      相关资源
      最近更新 更多