Questions tagged [odata]

The Open Data Protocol (OData) is a standardized protocol for building REST APIs. OData specifies many best practices for REST APIs, including a terse, hypermedia-oriented JSON format. Use this tag for all specification versions (v2, v3, v4.x).

The Open Data Protocol (OData) is a standardized protocol for building REST APIs. It is a web protocol for querying and updating data, which can be freely incorporated in various kinds of data access applications

OData v4 specifies many best practices for REST APIs including a terse, hypermedia-oriented JSON format.

OData v4 is an OASIS Standard, with more than 20 companies participating on the technical committee. Microsoft, SAP, Salesforce, and many other companies are strong advocates of the protocol as a solution to an otherwise fragmented REST API landscape.

This same standardization allows generic hypermedia clients to consume the service. , and are well known data clients that have support for consuming OData.

7563 questions
20
votes
3 answers

OData query filter for dateTime range

I have a DateTime property in the data returned by a service that looks like "SDateTime":"2014-06-29T03:30:00.000". I need to write a query to get a collection which has the date less than "2014-06-26T03:30:00.000" and greater than…
user2439903
  • 1,277
  • 2
  • 34
  • 68
20
votes
3 answers

How to expand multiple properties on OData

Consider I have this OData expression: http://services.odata.org/northwind/northwind.svc/Categories? $expand=Products/Category It will correctly expand the Products.Category. Now I want to expand another property too. For example…
mehrandvd
  • 8,806
  • 12
  • 64
  • 111
19
votes
2 answers

OData V4 modify $filter on server side

I would like to be able to modify the filter inside the controller and then return the data based on the altered filter. So for I have an ODataQueryOptions parameter on the server side that I can use to look at the FilterQueryOption. Let's…
goroth
  • 2,510
  • 5
  • 35
  • 66
19
votes
2 answers

How to pass Array to OData function in ASP.NET Web API implementation?

The specification of OData V4 states that it MUST be possible: https://issues.oasis-open.org/browse/ODATA-636. "Complex types and arrays can only be passed to functions through parameter aliases" When I'm trying to pass an array with OData…
Eugene D. Gubenkov
  • 5,127
  • 6
  • 39
  • 71
19
votes
2 answers

Web API and OData- Pass Multiple Parameters

Is it possible to get OData to do the following? I would like to be able to query a REST call by passing on parameters that may not be the primary key. Can I call a REST method like --> GetReports(22, 2014) or Reports(22,…
Nate
  • 2,044
  • 4
  • 23
  • 47
19
votes
2 answers

Abstract Generic ODataController Class Leads To 'No HTTP resource was found'

I am trying to abstract the auto-generated ODataController class in VS 2013 because the code looks identical across different controllers except the name of the POCO, so, I did the following: public abstract class ODataControllerBase :…
Mickael Caruso
  • 8,721
  • 11
  • 40
  • 72
19
votes
4 answers

Error Handling for ASP.NET Odata Web API

I'm interested in knowing what are the best practices being followed to raise exceptions in the ODataController. If you raise an exception in the method it is translated to response code of 500 by default and the content has details on the error. I…
user2883779
  • 191
  • 1
  • 1
  • 3
19
votes
2 answers

How to expose a MySQL database as OData

I currently have a mySQL database and want interact with it using OData. In other words, I want to expose the data in this form: http://services.odata.org/Northwind/Northwind.svc/ I've found several tutorials on how to do this (for example,…
AllieCat
  • 3,890
  • 10
  • 31
  • 45
19
votes
4 answers

How to consume OData service with Html/Javascript?

Our project currently uses Silverlight to consume an Odata service. This has made life pretty simple since we can just reference the OData service thus giving us generated service reference/entities. However there is some discussion on whether we…
AlvinfromDiaspar
  • 6,611
  • 13
  • 75
  • 140
18
votes
2 answers

Microsoft OData in .NET CORE 5 - Adding OData to services throws up a missing using directive yet the package is there

I am developing in .net core 5.0. (There is a tutorial by Sam Xu on moving to dotnet core 5) I have gone back to the absolute bare minimum with the most simple API project in Visual Studio. I had this working in my project earlier in the year and it…
si2030
  • 3,895
  • 8
  • 38
  • 87
18
votes
6 answers

config.MapODataServiceRoute error

I am currently following this guide -> Link to asp.net website As the guide says I added all the necessary packages via the nuget console and added the necessary usings to the WebApIConfig file. . But when I added the endpoint register method VS…
Robin
  • 2,704
  • 7
  • 30
  • 47
18
votes
1 answer

Web Api 2.2 with odata and $expand

I am using codefirst with odata. I have setup my models and with relationships. The query seems to be working successfully. I am only running in an issue when using $expand when expanding nested data. I followed the following link off Microsoft's…
TYRONEMICHAEL
  • 4,174
  • 4
  • 30
  • 47
18
votes
5 answers

Arguments of using WCF/OData as access layer instead of EF/L2S/nHibernate directly

We develop mostly low traffic but highly specialized web applications. Normally we use L2S, EF or nHibernate as access layer and then throws Asp.Net MVC to it and in which for normal crud operations we query the ISession/DataContext directly but for…
Carl Hörberg
  • 5,973
  • 5
  • 41
  • 47
18
votes
4 answers

OData $expand, DTOs, and Entity Framework

I have a basic WebApi service setup with a database first EF DataModel set up. I am running the nightly builds of WebApi, EF6, and the WebApi OData packages. (WebApi: 5.1.0-alpha1, EF: 6.1.0-alpha1, WebApi OData: 5.1.0-alpha1) The database has two…
Schandlich
  • 693
  • 1
  • 4
  • 21
17
votes
3 answers

Exclude certain Models from Swashbuckle-generated Swagger Schema in ASP.Net Core OData Project

I am using Swashbuckle to generate the Swagger documentation for my ASP.Net Core 3.1 OData project. The generation of the controllers' methods is perfect. And it is correctly generating the schema based on the models, except for one thing: For each…
Shawn de Wet
  • 5,642
  • 6
  • 57
  • 88