1
votes

I am using Web API to create RESTful services. I decided to using Accept header as a api versioning mechanism by following this implementation. http://blog.maartenballiauw.be/post/2013/03/08/Custom-media-types-for-ASPNET-Web-API-versioning.aspx

Accept: application/json; version=1

For entity standardization and query capabilities, I planned to use Odata. The problem currently I see is that the odata only supports(or only I know) the entity versioning using url.

 modelBuilder1.EntitySet<V1.Product>("Products");
 modelBuilder2.EntitySet<V2.Product>("Products");

 Microsoft.Data.Edm.IEdmModel model1 = modelBuilder1.GetEdmModel();
 Microsoft.Data.Edm.IEdmModel model2 = modelBuilder2.GetEdmModel();

 config.Routes.MapODataRoute("ODataRoute1", "api\v1", model1);
 config.Routes.MapODataRoute("ODataRoute2", "api\v2", model2);

Is there any solution available for to configure odata to consider accept header ?

Thanks in Advance.

1
Entityset names cannot have / in them. - RaghuRam Nadiminti
Thanks for pointing it out. I updated the thread. - Vytheese

1 Answers

2
votes

We have a very good sample on versioning using web API OData. You can find it here