I am suffering from the following problem when trying to perform a POST to create a new REST resource on a nested URL with my own .Net WebApi based REST-service.
Please imagine the following url api/parents/{parentId}/children on which I want to perform a POST to add another child.
This is very similar to the problem described in: Using asp webapi to post a nested resource. But in global.asax I do not succeed to define with routes.MapHttpRoute(...) a route which calls a method of my Parents-controller containing the {parentId} as well as the Child object to be added/posted, e.g. calling:
[HttpPost]
public HttpResponseMessage AddChildToParent(int parentId, Child newChild) {
//implementation
}
(This is also the difference to the answer of the above mentioned question, since it does not provide any object which could be added.)
I was searching the Web, but unfortunately I could not find a solution - probably also, because I could not even find an official documentation of the semantics of the defaults-object used as parameter for the MapHttpRoute() method.
Can anybody please suggest a working routing definition for my problem or at least post a link to a useful documentation of the defaults-object used in MapHttpRoute()? Thanks a lot!