Questions tagged [odata-v4]

The Open Data Protocol (OData) is a standardized protocol for building REST APIs. 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. Excel, Tableau, and QlikView are well known data clients that have support for consuming OData.

167 questions
30
votes
12 answers

How to get Web API OData v4 to use DateTime

I have a fairly large data model that I want to expose using Web API OData using the OData V4 protocol. The underlying data is stored in a SQL Server 2012 database. That database has many DateTime columns in it. As I was wiring it up I got an error…
Vaccano
  • 78,325
  • 149
  • 468
  • 850
15
votes
3 answers

Web APi OData V4 Issue "The entity '' does not have a key defined

When I run the following sample it is throwing the following exception... Additional information: The entity 'TestEntity' does not have a key defined. I have configured the key using code first entity…
Hanu
  • 173
  • 1
  • 2
  • 5
11
votes
1 answer

How to unit test OData Client?

I'm using Web Api OData v4 on the server and OData Client code generator on the client. It works fine, but I don't know how to test the code on the client. On the server I expose a "Levels" dbSet. Here's a snippet code on the client: public class…
The One
  • 4,560
  • 5
  • 36
  • 52
9
votes
4 answers

oData v4 what are Functions and Actions in simple terms?

In oData 4.0 Actions and functions are frequently referred. I couldn't get what are they and how they are different. Are function same functions we have in any programming language or something else ? What are Actions ? and how both are different.…
user576510
  • 5,777
  • 20
  • 81
  • 144
9
votes
1 answer

OData v4 Routing Prefix?

I have a side-by-side Web API 2.2 APIController and OData v4 ODataController. My APIController uses routing attributes internally like this (there are no predefined routing defaults): [RoutePrefix("api")] public class MyController :…
Xorcist
  • 3,129
  • 3
  • 21
  • 47
8
votes
1 answer

OData Connected Service vs OData V4 Client Code Generator

OData Connected Service OData V4 Client Code Generator I know that these extensions are used to generate client code based on Odata service. What is the difference between OData Connected Service vs OData v4 Client Code Generator extension. What…
Rahul
  • 2,431
  • 3
  • 35
  • 77
7
votes
0 answers

OData V4 using Vocabulary Annotations to pass data annotations

Does anyone know how to set / read vocabulary based annotations in the metatdata for OData V4 to define things like max string length? There is an article Client Annotation Support but it does not show any sample code and I'm not 100% sure they are…
goroth
  • 2,510
  • 5
  • 35
  • 66
7
votes
2 answers

Applying Distinct to OData query

I want to get a list of distinct values from my OData endpoint. But distinct or group by isn't supported yet. My URI query looks something like this GET /odata/Products?$select=foo & $top=10 & $count=true & distinct=true My…
Snæbjørn
  • 10,322
  • 14
  • 65
  • 124
7
votes
2 answers

Error when using $select and $expand with Odata v4.0 on Web API 2.2

I have a web api 2.2 that is configured for OData v4. I want to return a user by ID and include only the user group Id's that the user is a member of. When I do this http://localhost/User?$filter=id eq…
Brett
  • 321
  • 4
  • 15
6
votes
2 answers

How to filter SQL Server DateTime using .NET Core WebAPI with OData v4

I am running a simple .NET Core WebApi application with OData Query v4 and SQL Server 2012. This works, but it's extremely slow: GET /api-endpoint?$filter=date(MyDateTimeField) ge 2018-01-01&$top=100 SQL Query generated by the URL above: SELECT TOP…
AndreFeijo
  • 10,044
  • 7
  • 34
  • 64
6
votes
2 answers

OData filtering before selecting inside an expand query

I am writing a query for metadata in Dynamics 365, but I think this problem could be universal for any OData query. My problem is as follow: In Dynamics, we can have multiple types of fields in entities, such as strings, bools or lookup. I want to…
Metju.Perry
  • 89
  • 2
  • 8
6
votes
1 answer

In OData, is there a way to order by the first element in an array?

I have an OData 4 endpoint I call for displaying data in a table. One of the columns has a set of data concatenated from a string array within my element. Is there a way to order by the first element in the array? My element could look like this: [ …
Jereme
  • 1,445
  • 1
  • 16
  • 32
6
votes
2 answers

OData V4 $expand nested $filter and $orderby -- combine $filter and $orderby inside expand

I currently have an OData V4 service that has the following model. "Category" -- "Codes" For each category there can be many codes. I need to $expand the Codes, $filter where Active = true and then $orderby Codes.Description. Currently the…
goroth
  • 2,510
  • 5
  • 35
  • 66
6
votes
6 answers

Override host of webapi odata links

I'm using WebAPI 2.2 and Microsoft.AspNet.OData 5.7.0 to create an OData service that supports paging. When hosted in the production environment, the WebAPI lives on a server that is not exposed externally, hence the various links returned in the…
Eivind Gussiås Løkseth
  • 1,862
  • 2
  • 21
  • 35
6
votes
1 answer

OData WebApi 2 Error Handling

In my web service, I override the ExceptionHandler, but it's not clear to me how you would format the exception to fit the OData Error standard. Perhaps i'm approaching it wrong since I can't find any examples online. From my understanding, with…
darewreck
  • 2,576
  • 5
  • 42
  • 67
1
2 3
11 12