I need to do a post to receive back JSON to populate my CoreData. Up to this point I was only do GETs.
No matter what combination when I view the call from Charles, nothing is in the body.
let storedProcedureParams =
[
"params": [
[
"name": "p_latitude",
"param_type": "IN",
"value": latitude
],
[
"name": "p_longitude",
"param_type": "IN",
"value": longitude
],
[
"name": "p_distance",
"param_type": "IN",
"value": distance
],
[
"name": "p_user",
"param_type": "IN",
"value" : user
],
[
"name": "p_appKey",
"param_type": "IN",
"value" : appDelegate.api_key
]
],
"schema": [
"id": "integer",
"complete": "boolean"
],
"wrapper": "record"
]
let mapping = RKObjectMapping.requestMapping()
mapping.addAttributeMappingsFromDictionary(storedProcedureParams)
let requestDescriptor = RKRequestDescriptor(mapping:mapping,objectClass:Store.self, rootKeyPath:nil, method:RKRequestMethod.POST)
objectManager.addRequestDescriptor(requestDescriptor)
objectManager.addResponseDescriptor(responseDescriptor )
objectManager.requestSerializationMIMEType = RKMIMETypeJSON
objectManager.postObject(storedProcedureParams, path: "_proc/StoresByDistance", parameters: nil,
success:{ operation, mappingResult in
NSLog("success")
},
failure:{ operation, error in
NSLog("Error loading list': \(error!.localizedDescription)")
//return nil
}
);
Anything obvious?
Evidently, I had to set the requestDescriptor to nil, and then use the params which sent it in the body.