We have an OData 4 WebAPI controller with two GET methods, one that returns a Thing
entity collection (IQueryable<Thing>
) and one that returns a single Thing
(SingleResult<Thing>
) based on the provided key (using the FromODataUri
attribute).
When run, IIS and IISExpress happily return an entity collection when you request http://localhost:48213/odata/Things
, but return a 404.0 - Not Found
when we request a single entity on http://localhost:48213/odata/Things(1)
(the notification coming from MapRequestHandler
and the Handler being StaticFile
). The GET method for the single entity is not executed.
The project was created following this tutorial and I think we've followed it correctly. This feels like a URL mapping issue (perhaps web.config
or IIS/IISExpress config related), because the URL is extension-less and contains parentheses. However, I guess it could be the route configuration or some other thing I don't get. Does anybody have any ideas?
The Thing
type declaration is as follows (in F#):
[<CLIMutable>]
type Thing =
{ Id : string
Name : string }
What is the type of the key parameter in your controller ? If it is string, you should have the url:
/odata/Things('1')