iphone - Delete Object in Restkit .20 did not take JSON Values -
i have api used delete record in server db. used construct api request id .it working curl, in restkit seems give error. curl is:
curl -d '{eve:{mod_policy:"current"}}' -x delete -h content-type:application/json https://myurl.com/eve/eve_id?token=my_aut_token\&apikey=myapi_key.
i checked post & patch. takes json
correct form.
my restkit code sample:
rkobjectmapping *requestmapping = [rkobjectmapping requestmapping]; [requestmapping addattributemappingsfromdictionary:@{ @"modpolicy" : @"mod_policy"}]; rkrequestdescriptor *requestdescriptor = [rkrequestdescriptor requestdescriptorwithmapping:requestmapping objectclass:[event class] rootkeypath:@"eve"]; rkobjectmapping *responsemapping = [rkobjectmapping mappingforclass:[events class]]; [responsemapping addattributemappingsfromdictionary:@{ @"data" : @"data", @"status":@"status" }]; rkresponsedescriptor *responsedescriptor = [rkresponsedescriptor responsedescriptorwithmapping:responsemapping pathpattern:nil keypath:@"" statuscodes:[nsindexset indexsetwithindex:200]]; [objectmanager addrequestdescriptor:requestdescriptor]; [objectmanager addresponsedescriptor:responsedescriptor]; nsstring * urlpath = [nsstring stringwithformat:@"/eve/%@?token=%@&apikey=%@",eventid,logintoken,apikey]; [objectmanager deleteobject:hubeve path:urlpath parameters:nil success:^(rkobjectrequestoperation *operation, rkmappingresult *result) { dlog(@" response code %d",operation.httprequestoperation.response.statuscode); events * _event = [result firstobject]; dlog(@"status %@",_event.status); if([_eventt.status isequaltostring:@"success"]) { dlog("move next"); } } failure:^(rkobjectrequestoperation *operation, nserror *error) { dlog("error %@",error); }];
some log details, if send deleteobject in request:
request.body=(null) //restkit log
or if send post object/patch object
request.body={"eve":{"mod_policy":"all"}} //restkit log
request mapping explicitly not performed delete
requests. restkit expects when deleting using system add parameters url. need plan other method delete. using restkit mapping operation create payload data , using methods create url request , setting body data explicitly.
Comments
Post a Comment