POST 中的 Restkit url 映射

Restkit url mapping in POST

我想POST这个URL文件/:ID/resend 和正文请求

{
  "resend":{
    "email": "foo@example.com"
  }
}

和回应

{
   "result":{
      "code": "123",
      "message": "foo"
   }
}

我做了我的请求和响应描述符以及这条路线:

RKRoute *documentResendRoute = [RKRoute routeWithClass:[LDocument class]
                                         pathPattern:@"documents/:ID/resend"
                                              method:RKRequestMethodPOST];

当我发布文档对象时

[[RKObjectManager sharedManager] postObject:self
                                       path:@"documents/:ID/resend" 
                                 parameters:queryParams
                                    success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
                                        //success code
                                    } failure:^(RKObjectRequestOperation *operation, NSError *error) {
                                        //failure code
                                    }];

Restkit 不映射 URL 中的 :ID。结果应该是这样 "documents/880/resend" 但在日志中我可以看到 "documents/:ID/resend" 并且调用失败。

LDocument 的 ID 为 属性。

我错过了什么?或者我应该怎么做?

谢谢,亚历杭德罗

当您调用 postObject 时,您不应该指定路径,如果您这样做,则不会使用路由器并且不会注入参数。只需将路径设置为 nil.