The goal is to allow these four endpoints:
POST v1/invoices<br/>
POST v1/invoices/12345<br/>
POST v1/invoices/12345/attachment<br/>
POST v1/invoices/12345/image
Routing entries:
routes.MapHttpRoute(
name: "InvoiceAttachments",
routeTemplate: "v1/invoices/{id}/attachments",
defaults: new { controller = "invoices", action = "PostAttachment" }
);
routes.MapHttpRoute(
name: "InvoiceImages",
routeTemplate: "v1/invoices/{id}/images",
defaults: new { controller = "invoices", action = "PostImage" }
);
These are my four function definitions in the controller:
[HttpPost]
[ActionName("PostAttachment")]
public HttpResponseMessage PostAttachment(int id)
[HttpPost]
[ActionName("PostImage")]
public HttpResponseMessage PostImage(int id)
[HttpPost]
public HttpResponseMessage Post(int id)
[HttpPost]
public HttpResponseMessage Post()
Yet when I post an invoice using the first URI, the route that gets recognized is the attachments route. How do i have endpoints with different sections after the ID variable?