Questions tagged [asp.net-web-api-odata]

ASP.NET 4.x Implementation of OData Services that supports both v3-v4 of the OData Protocol. DO NOT use this tag for [asp.net-core] related questions! Use this tag if your question directly relates to the ASP.NET server-side implementation of OData services, but also include the version specific tag [odata-v3] or [odata-v4]. Only include the non-specific [odata] tag if the question has broader client-side implications.

The ASP.NET Web API OData package offers support for the OData protocol in ASP.NET Web API.

OData is a standard protocol for creating and consuming data. The purpose of OData is to provide a protocol that is based on Representational State Transfer (REST) for create, read, update, and delete (CRUD) operations. OData applies web technologies such as HTTP and JavaScript Object Notation (JSON) to provide unified convention based access to information from various programs. OData provides the following benefits:

  • It lets developers interact with data by using RESTful web services.
  • It provides a simple and uniform way to share data in a discoverable manner.
  • It enables broad integration across products.
  • It enables integration by using the HTTP protocol stack.

Two key defining features of OData over traditional RESTful APIs are the URL conventions that make it possible to compose queries that request only the specific fields and navigation links from resources that are needed on the client as well as the ability to partially update resources using the PATCH HTTP verb.

  • Together these features allow individual clients to reduce the data sent across the wire without needing changes in the API or data schema to support this.

ASP.NET Web API supports both Version 3 and Version 4 of the OData protocol.
Learn more about ASP.NET Web API OData on MSDN

The code from this package to implement this protocol makes heavy use of Language Integrated Query (LINQ) expressions to support deferred execution of client requests, in a sense the ODataLib translates a specific set of URL queries into LINQ queries.

While not required, the ASP.NET implementation has extensive support for using Entity-Framework to access the data layer, reducing the code necessary to expose EF data schemas as OData resources. For this reason Posts on SO related to this tag will often include EF references and concepts.

You can also find more information on:

134 questions
2
votes
1 answer

Name of 'Container' as an entity is not allowed in Web API OData

My list of entities includes one called 'Container'. (My company deals with containers a lot and it is a fairly "Set In Stone" term.) So when I modeled my data for them, I naturally called them Containers. That means I have a class called…
Vaccano
  • 78,325
  • 149
  • 468
  • 850
2
votes
3 answers

How do you use optimistic concurrency with WebAPI OData controller

I've got a WebAPI OData controller which is using the Delta to do partial updates of my entity. In my entity framework model I've got a Version field. This is a rowversion in the SQL Server database and is mapped to a byte array in Entity Framework…
2
votes
3 answers

Web API OData Typeless support for $select query option

I am working with the new typeless support in ASP.NET Web API 2 OData. I am interested in providing support for the $select query option. How do I omit the structural properties from the EdmEntityObject that were not selected by the $select query…
Brad Flood
  • 21
  • 3
2
votes
0 answers

Web api odata sending a long $filter string results in maxurlstring exceeds error

I am trying to send a large $filter string to my webapi odata endpoint.But it gives me error saying the size of request headers are too long/maxurlstringlength exceeds. Is there a way to send the $filter in "POST" request and query the odata…
Ramesh
  • 31
  • 2
2
votes
0 answers

MongoDB + OData: Unable to determine the serialization information for the expression:

I'am trying to implement a simple log viewer using the KendoUI grid, MongoDB and OData (using Microsoft.Data.OData). An "eq" query works fine for date and strings, but if I use something else like "substringof" I get an exception: Unable to…
2
votes
0 answers

Content-ID references in ASP.NET OData batch requests

I have an ASP.NET WebApi OData service, and I am trying to consume it from JavaScript using JayData. My model is as follows: class Parent { ICollection Children; } class Child { ICollection Parents; } I'm trying to add a new…
2
votes
1 answer

Wrong OData EntityContainer Schema Namespace

I'm using ASP.NET MVC WebApi as OData service and I want to query this OData service with Jaydata. Jaydata has a command line util (JaySvcUtil.exe) that downloads the service definition ($metadata) and creates a full featured JayData / JavaScript…
Bas
  • 678
  • 6
  • 10
1
vote
0 answers

Running a long running background task from OData/Web API request running on Azure App Service (.Net Framework)

We have a pretty memory heavy OData/Web API written in C# and running on an Azure App Service instance. Some specific endpoints which get used rarely can take a long time to execute (20s) or they can take an extremely long time (10min) depending on…
Amir
  • 317
  • 2
  • 11
1
vote
2 answers

WEB API OdataController POST call returns 406 Not Acceptable

When I'm sending a POST request to ODataController, record is inserted in the table, but I get the following error "The remote server returned an error: (406) Not Acceptable." GET call for the same controller works just fine. The URL Im trying to…
1
vote
1 answer

ODataRoutePrefix not working for 3rd level

When I try to use a third level segment with [ODataRoutePrefix] attribute it throws an error like this: The path template '[TEMPLATE]' on the action 'Get' in controller 'CONTROLLER-NAME' is not a valid OData path template. Found an unresolved path…
1
vote
1 answer

Delete record with composite primary key in OData

I have an entity Student. Below is the signature of delete method in ASP.net WebAPI for OData. public async Task Delete([FromODataUri] int key) The Student has composite primary key. When called from Postman,…
Nands
  • 379
  • 3
  • 19
1
vote
1 answer

Add list of entity as parameter

Is it possible to retrieve a list of entities as a parameter for an action in c# odata? Tried the following but it casues the entire controller to not work: [HttpPost] [NhSessionManagement()] [ODataRoute("BatchUpdate")] public async…
Robert
  • 2,357
  • 4
  • 25
  • 46
1
vote
1 answer

How to change the service root in webapi odata v3?

Have webapi odata v3 endpoint implemented with Microsoft.AspNet.WebApi.OData, exposed under API management, how do I change the service root path, instead of returning the azurewebsite one return the api management URL.
1
vote
1 answer

ASP.NET Web API OData (v4) POST on Entity with SPATIAL PROPERTY

What's the right way to POST an Entity with a SPATIAL PROPERTY on ASP.NET Web API OData (v4)? Serialization on GET works fine, but everything I try in the POST causes the model to go null. Is POST supported at all? Thanks in advance. public class…
1
vote
0 answers

ODATA filtering "$top=50" causing unexplained repetition

I'm working on an API and the object I'm dealing with has many, many records. I'm accessing it via this URL: {{api_root}}/Objects?$top=50 For time keeping, I'm limiting the query to 50. However, I recently added a list of strings IDs and have ran…
CSquid
  • 25
  • 6
1 2 3
8 9