我想POST这个URL文件/:ID /重发和身体请求
{ "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属性。
我错过了什么? 或者我该怎么做?
谢谢,亚历杭德罗
I want to POST this URL documents/:ID/resend and body request
{ "resend":{ "email": "foo@example.com" } }and response
{ "result":{ "code": "123", "message": "foo" } }I did my request and respond descriptors and this route:
RKRoute *documentResendRoute = [RKRoute routeWithClass:[LDocument class] pathPattern:@"documents/:ID/resend" method:RKRequestMethodPOST];and when I'm posting the document object
[[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 doesn't map the :ID in the URL. It should result something like this "documents/880/resend" but at logs I can see "documents/:ID/resend" and the call fail.
LDocument has the ID property.
What did I miss? or How should I do this?
Thanks, Alejandro
最满意答案
当您调用postObject您不应该指定路径,如果这样做,将不使用路由器并且不注入参数。 只需将路径设置为nil即可。
When you call postObject you shouldn't be specifying the path, if you do this the router won't be used and the parameter not injected. Just set the path to nil.
更多推荐
发布评论