Reputation: 883
My controller code is: [EnableQuery] public class LibWorkspacesController : ODataController {
[ODataRoute("LibWorkspaces(company={key})")]
public IHttpActionResult GetLibWorkspaces([FromODataUri] string company)
{
LibWorkspaces libWorkspaces = new LibWorkspaces();
return Ok(libWorkspaces.getList(company).AsQueryable());
}
There is a: builder.EntitySet("LibWorkspaces"); in the webapiconfig
But I am getting the error "The path template 'LibWorkspaces(company={key})' on the action 'GetLibWorkspaces' in controller 'LibWorkspaces' is not a valid OData path template"
What do I need to do to return a generic list for a parameter? Thanks in advance
Upvotes: 0
Views: 386
Reputation: 3380
user14268:
For [ODataRoute("LibWorkspaces(company={key})")]
, just make sure company
is same as the key name (Case sensitive). Besides, the parameter name of GetLibWorkspaces
should be same as the string in {}
. Therefore, in your scenario, your action should have the following definition:
public IHttpActionResult GetLibWorkspaces([FromODataUri] string key)
For single key scenario, you can omit the key name in the ODataRoute
attribute. For example:
[ODataRoute("LibWorkspaces({anyKeyName})")]
public IHttpActionResult GetLibWorkspaces([FromODataUri] string anyKeyName)
{ ... }
Thanks.
Upvotes: 0