Note that there are some explanatory texts on larger screens.

plurals
  1. POMake a POST request using RestKit
    text
    copied!<p>I wanna make a POST request using RestKit, I work with RKObjectManager using a method postObject. The body of the request is an array of integers, JSON representation is something like [2348, 9864, 3645]. I have added a RKResponseMapping for response of service and work fine, but on service side always an array is null. What is a RKRequestMapping then I have to add? What I missing?</p> <p>My code look like:</p> <pre><code>- (void) sendPOSTRequest:(NSArray*) postBody{ RKObjectManager *manager = [RKObjectManager managerWithBaseURL:[NSURL URLWithString:baseUrl]]; RKObjectMapping *responseMapping = [RKObjectMapping mappingForClass:[RKJSONArrayResponse class]]; [responseMapping addAttributeMappingsFromDictionary:@{ @"Code" : @"code", @"Success":@"success", @"Content":@"content", @"Error": @"error"}]; RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:responseMapping method:RKRequestMethodPOST pathPattern:@"/api/Requisitions/SendReport" keyPath:nil statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]; RKObjectMapping *requestMapping = [RKObjectMapping mappingForClass:[NSArray class]]; RKRequestDescriptor *requestDescriptor = [RKRequestDescriptor requestDescriptorWithMapping:requestMapping objectClass:[NSArray class] rootKeyPath:nil, method:RKRequestMethodPOST]; [manager addRequestDescriptor:requestDescriptor]; [manager addResponseDescriptor:responseDescriptor]; [self.manager postObject:postBody path:@"/api/Requisitions/SendReport" parameters:nil success:success failure:failure]; } </code></pre> <hr> <p>The service code is written in C # with Web Api, here is where you will always receive the variable "report" as null.:</p> <pre><code>public JsonResponse&lt;int[]&gt; SendReport(int[] report){} </code></pre>
 

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