Note that there are some explanatory texts on larger screens.

plurals
  1. PORestkit cannot serialize request to xml
    primarykey
    data
    text
    <p>I am using RestKit 0.20.0 to work with API (xml).</p> <p>But when I try to make XML POST request and setup mapping, request body is always <code>null</code></p> <pre><code>RKObjectManager* objectManager = [RKObjectManager managerWithBaseURL:[NSURL URLWithString:@"http://url:4465/paci/v1.0"]]; [RKMIMETypeSerialization registerClass:[RKXMLReaderSerialization class] forMIMEType:@"application/xml"]; objectManager.requestSerializationMIMEType = RKMIMETypeXML; [objectManager setAcceptHeaderWithMIMEType:RKMIMETypeXML]; </code></pre> <p>Mapping:</p> <pre><code>RKObjectMapping *createServerMapping = [RKObjectMapping mappingForClass:[NSMutableDictionary class]]; [createServerMapping addAttributeMappingsFromDictionary:@{ @"name": @"name", @"description": @"description", @"ramSize": @"ram-size", }]; RKRequestDescriptor *createServerDescriptor = [RKRequestDescriptor requestDescriptorWithMapping:createServerMapping objectClass:[NSMutableDictionary class] rootKeyPath:@"ve" method:RKRequestMethodPOST]; [objectManager addRequestDescriptor:createServerDescriptor]; </code></pre> <p>Object:</p> <pre><code>IBCreateServer *createServerRequest = [[IBCreateServer alloc] init]; createServerRequest.name = @"web40"; createServerRequest.description = @"testtest"; createServerRequest.ramSize = @"512"; </code></pre> <p>post Object:</p> <pre><code>[objectManager postObject:createServerRequest path:@"ve" parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {} failure:^(RKObjectRequestOperation *operation, NSError *error) {}]; </code></pre> <p>And the result of this request is:</p> <pre><code>request.headers={ Accept = "application/xml"; "Accept-Language" = "en;q=1, fr;q=0.9, de;q=0.8, zh-Hans;q=0.7, zh-Hant;q=0.6, ja;q=0.5"; } request.body=(null) </code></pre> <p>Body is always null. What i am doing wrong? This happens only with request, response XML parsing works correctly.</p> <p><strong>EDIT:</strong> if I serialize to json, it works correctly</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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