Swift RestKit Post not including post data -
i'm not able data posted using following code. i've tried related posts on still can't work.
added in request descriptor, have nsdictionary mapping parameters, tried inversemapping, ect.
var parms = wearrequestparms() parms.height = height parms.width = width parms.density = density if let userid = alpinemetricshttpclient.getuserid() { parms.userid = userid } var objectmanager : rkobjectmanager? objectmanager = alpinemetricshttpclient.setupclient() // var mapping = rkobjectmapping(forclass:wearrequestparms.self) var mapping = rkobjectmapping.requestmapping() let requestmappingobjects = ["iscircle","height","width","density","userid","wearmodel","platform"] let dict : nsmutabledictionary = ["iscircle":"iscircle","height":"height","width":"width","density":"density","userid":"userid","wearmodel":"wearmodel","platform":"platform"] mapping.addattributemappingsfromarray(requestmappingobjects) // mapping.addattributemappingsfromdictionary(dict [nsobject : anyobject]) // var newrequestmapping = mapping.inversemapping() let requestdescriptor = rkrequestdescriptor(mapping: mapping, objectclass: wearrequestparms.self, rootkeypath: "", method: rkrequestmethod.post) objectmanager!.addrequestdescriptor(requestdescriptor) // response let responsemapping = rkobjectmapping(forclass:poststatus.self) var responsedescriptor = rkresponsedescriptor( mapping: responsemapping ,method:rkrequestmethod.post ,pathpattern : "/api/user/registerweardevice" ,keypath :"" ,statuscodes : nsindexset(index:200)) objectmanager!.addresponsedescriptor(responsedescriptor) rkobjectmanager.sharedmanager().postobject(parms, path: "/api/user/registerweardevice", parameters: nil, success:{ operation, mappingresult in nslog("success") defaults.setbool(true, forkey: "weardimensionssynced") }, failure:{ operation, error in nslog("error loading metric list': \(error!.localizeddescription)") //return nil } );
i shouldn't have been using rkobjectmanager.sharedmanager().postobject
this caused previous values overwritten or interfered with.
i switched
rkobjectmanager.sharedmanager().postobject
with
objectmanager!.postobject
Comments
Post a Comment