25

I'm starting a project that has to expose a RESTful service that will be consumed by a wide variety of clients of several OSs.

I'm reading about Web API and OData using Web API and it's hard for me to decide what to use, the plain Web API or the OData one.

What are some notable pros and cons?

Update
Would you guys be kind enough and comment on why this question is "primarily opinion based"? where exactly do you see any personal opinion here?

7
  • 2
    I would UNvote to close if there's an option but we can always Vote to reopen if that reaches that point. I too would like to read here a detailed answer of the pros and cons. The link you provided does not provide much insight to your question. I'll help dig into this when time permits. Commented Jul 7, 2015 at 6:17
  • @vonv. Thanks! I found a nice article that shed light on the subject, check my answer. Anyway, not related to the question, are you familiar with OData? I'd like to know 1) Does OData provide validation functionality that can work with DataAnnotations? 2) Are there client generators or scaffolding for web-apps, WUA etc.? Something like RIA Services R.I.P Commented Jul 7, 2015 at 8:15
  • 1
    I actually have no idea @Shimmy and that's the reason I starred this post. I am learning a new thing here as well. Commented Jul 7, 2015 at 8:29
  • I would consider (a true REST) WebAPI an exposer of a 'domain' model (oversimplified analog: database tables, columns with CRUD) . OData provides a query mechanism on top of that (oversimplified analog: T-SQL). Using the OData standard allows for granular selection and retrieval (including references) from the "user of the API" where as with a WebAPI you would have to "make functions" to do 'specific' selects/queries. I do not know, but doubt, Asp.Net MVC control attributes are supported by OData. Commented Jul 8, 2015 at 7:24
  • @MarvinSmit good point, that might be a boomer. If Razor doesn't support OData I'm gonna stick to plain WebAPI, do you know for sure it's not supported? Commented Jul 8, 2015 at 10:45

1 Answer 1

4

I've found this great post by Julie Lerman, that explains Web API and OData, and that OData is like a Web API with added a WCF-like feature set.

One of the features is easy prototypes of generic CRUD controllers.
The article is more detailed and clear.

Sign up to request clarification or add additional context in comments.

4 Comments

I am finding that OData seems to be great for reading data only (the R in CRUD). Because aside from authorization, everything can be handled in the query usually, and if you need something more complex, then exposing OData over WebAPI can still be done (so the complex models are built on the server). Writing/deleting/updating I'm not sure. Because either way, these "events" may not be straight forward. So I don't see OData being useful in this department at all really.
@Worthy7 Technically you're right. Anyway, OData is specifically useful when you want to give the client the freedom in obtaining, refining, filtering ,caching, and sorting the data.
I actually did a bit of research and it seems it can be more straightforward than I thought. Using OData Actions/Function, which essentially allow you to run functions which are held server-side. The 'Invoking Bound Actions' sections here: odata.org/getting-started/basic-tutorial/#operation
I find it strange that Microsoft create all these complex technologies and neglect to make it crystal clear when to use which!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.