Note that there are some explanatory texts on larger screens.

plurals
  1. PORestKit 0.20.0 - getObjectsAtPath with JSON HTTP Body request
    text
    copied!<p>In <a href="https://github.com/RestKit/RestKit/" rel="nofollow">RestKit</a> Version 0.10.x I used</p> <pre><code>[[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"/special/path" usingBlock:^(RKObjectLoader *loader) { loader.objectMapping = aMapping; loader.delegate = _delegate; loader.method = RKRequestMethodPOST; loader.userData = [MobileGatewayReauthentication class]; loader.params = [anDictionary toJsonRKParam]; }]; </code></pre> <p>to add a <code>NSDictionary</code> to <code>loader.params</code> to send a collection of parameters as the HTTP body of the request.</p> <hr> <p>Since RestKit 0.20.0 the method <code>loadObjectsAtResourcePath</code> has been replaced by the following method, where it is no longer possible to pass a <code>NSDictionary</code> in <code>parameters</code>, which is used as HTTP Body (JSON encoded):</p> <pre><code>[RKObjectManager.sharedManager getObjectsAtPath:path parameters:params success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) { NSLog(@"success"); } failure:^(RKObjectRequestOperation *operation, NSError *error) { NSLog(@"failure"); }]; </code></pre> <p>When working with <code>[[RKObjectManager sharedManager].HTTPClient</code> (<a href="https://github.com/AFNetworking/AFNetworking" rel="nofollow">AFNetworking</a>) it works like a charm when setting:</p> <pre><code>[[RKObjectManager sharedManager].HTTPClient setParameterEncoding:AFJSONParameterEncoding]; [[RKObjectManager sharedManager].HTTPClient postPath:path parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"Response: %@", operation.responseString); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"Error: %@",error.localizedDescription); }]; </code></pre> <p>But I need the higher-level object mapper.</p> <hr> <pre><code>[[RKObjectManager sharedManager].HTTPClient setParameterEncoding:AFJSONParameterEncoding]; </code></pre> <p>has no effect on [RKObjectManager sharedManager] but</p> <pre><code>[[RKObjectManager sharedManager].HTTPClient setDefaultHeader:@"aHeader" value:@"aValue"]; </code></pre> <p>has. So I assumed that <code>setParameterEncoding</code> works, too.</p> <p>Is it a bug, is it not yet implemented, or have I missed something?</p> <p>Thanks a lot.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload