I have a web service that requires a two part query to fully get the information I need. I can query for the list of all vehicles via a GET request to /vehicles.json, which gives me a list of all vehicles like this:
{
vehicles: [
{
vehicle_name: "Sam's Toyota Corola",
uri: ".../vehicle/1001.json"
},
{
vehicle_name: "John's Honda Accord",
uri: ".../vehicle/1002.json"
}
]
}
The uris are the unique ids. Then if I want more information I can query
for the details of a vehicle via a GET request to the vehicle uri, i.e. /vehicle/1001.json, which gives me the details for a vehicle like this:
{
vehicle: {
engine: "V6",
sunroof: "no"
}
}
I’d like to represent a vehicle with one Core Data type that contains: name, uri, engine, and sunroof, but have two routes in RestKit mapped to the same CoreData type, like this:
// Map the list of all vehicles route
[objectManager.router routeClass:[CDVehicle class] toResourcePath:@"/vehicles.json" forMethod:RKRequestMethodGET];
// Map the show of a specific vehicle route
[objectManager.router routeClass:[CDVehicle class] toResourcePath:@"/vehicle/(vehicleID).json" forMethod:RKRequestMethodGET];
RestKit doesn’t like this, and gives me an error that there are two routes for the GET method mapped to the same thing. Why?!? Surely this can be done, seeing as how you can do practically anything with RestKit.
Does anyone know how to do this?
This question is kind of old but I googled out your question and a similar one, and the other one has a good answer, just in case you still interested, please refer to this post: How do I have two post routes for the same class in RestKit
They are talking about postObject, but get method in RestKit can also do the same thing.