在POST中的Restkit url映射(Restkit url mapping in POST)

编程入门 行业动态 更新时间:2024-10-26 23:40:07
在POST中的Restkit url映射(Restkit url mapping in POST)

我想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.

更多推荐

本文发布于:2023-08-02 12:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1375412.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Restkit   POST   mapping   url

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!