4

I want to have a route like:

/Accounts(id)/Orders 

where I can execute a POST to create an order. I can't find a way to add this route using OData in WebApi. For GET there is a convention to follow to get related collections, but I am not able to find any convention for posting new entities to a related collection.

Is there a standard way to handle this POST request with Web API 2 and OData 4 ?

Cosmin Vană
  • 1,562
  • 12
  • 28

1 Answers1

4

Added the following attributes to the method and it worked:

[HttpPost]
[ODataRoute("Accounts({key})/Orders")]
public IHttpActionResult Orders([FromODataUri] string key, OrderDto orderDto)
{

}
Cosmin Vană
  • 1,562
  • 12
  • 28