Thursday, 15 August 2013

Restkit Response in text/xml -



Restkit Response in text/xml -

i have ws homecoming plist. using restkit , map response.

so first initilialize objectmanager this:

sharedinstance.manager = [rkobjectmanager managerwithbaseurl:[nsurl urlwithstring:root_url]];

i take text/xml:

[[rkobjectmanager sharedmanager] setacceptheaderwithmimetype:rkmimetypetextxml];

and launch request:

nsmutableurlrequest *request = [[rkobjectmanager sharedmanager] requestwithobject:nil method:rkrequestmethodpost path:@"/foo/foo" parameters:nil]; rkmanagedobjectrequestoperation *operation = [[rkobjectmanager sharedmanager] managedobjectrequestoperationwithrequest:request managedobjectcontext:[bddmanager sharedinstance].manager.managedobjectstore.mainqueuemanagedobjectcontext success:^(rkobjectrequestoperation *operation, rkmappingresult *result) { nslog(@"loading mapping result: %d", result.count); } failure:^(rkobjectrequestoperation *operation, nserror *error) { nslog(@"fail!"); }]; [operation start];

finally error:

nslocalizeddescription=expected content type {( "application/x-www-form-urlencoded", "application/json" )}, got text/xml,

what doing wrong?

restkit 0.20.0rc1 not include xml serializer in main repository, can find 1 here: rkxmlreaderserialization.

install via cocoapods: (or add together source files project)

pod 'rkxmlreaderserialization', :git => 'https://github.com/restkit/rkxmlreaderserialization.git', :branch => 'master'

import header initialize restkit.

#import "rkxmlreaderserialization.h"

finally, register serialization class restkit. insert after initialize object manager , before set take header.

sharedinstance.manager = [rkobjectmanager managerwithbaseurl:[nsurl urlwithstring:root_url]]; [rkmimetypeserialization registerclass:[rkxmlreaderserialization class] formimetype:@"application/xml"]; [[rkobjectmanager sharedmanager] setacceptheaderwithmimetype:rkmimetypetextxml];

xml restkit mime-types

No comments:

Post a Comment