0

I'm trying to use RestKit because I'm expecting to make Core Data managed objects out of requests responses and it seemed like the framework was all about doing that and it seemed to be rather full featured.

But I'm having trouble getting my POST /user/login with parameters api_key=<value> (plus a separate JSON body) to end up a going out in a request like /user/login?api_key=<value>.

In the internals of RKObjectManager, requestWithMethod:path:parameters: does:

// NOTE: If the HTTP client has been subclasses, then the developer may be trying to perform signing on the request
NSDictionary *parametersForClient = [self.HTTPClient isMemberOfClass:[AFHTTPClient class]] ? nil : parameters;
request = [self.HTTPClient requestWithMethod:method path:path parameters:parametersForClient];

Do I have it right that this AFNetworking superclass method encodes parameters into the URL query? And does this mean the only way to ensure parameters are passed to that is to have my RKObjectManager use some subclass of AFHTTPClient?

And, according to the comment, supposedly this is only for sake of maybe a fringe case, something about request signing or something? Why is URL query-encoded request parameters not a common thing to do??

And getting things JSON encoded like I want does not seem to be as easy as I'd hoped either. Maybe it's a mistake for me to even try to use RestKit.

Pierre Houston
  • 1,631
  • 20
  • 33
  • Easiest is to just create the path with the parameter yourself, POST usually uses the body instead of the query. You can subclass to do it, but then would you use parameters for body later? You'd need to give more details about the JSON generation... – Wain Jun 18 '15 at 10:32
  • I realize now that it may, in fact, be a rather a oddball thing to do. See conversation at . I did indeed give up on RestKit, only to find that doing this in AFNetworking is a little tricky too. – Pierre Houston Jun 18 '15 at 19:08
  • RestKit is built on top of AFN, but underlying they're both trying to be true to HTTP general usage. Unfortunately a lot of servers, because of the people who design them, don't have the same goals... – Wain Jun 19 '15 at 09:00

0 Answers0