Search code examples
restodata

OData API with parameterized get operation


Is it possible to implement the get operation with filter parameters as below:

    public IHttpResult Get([FromODataUri] int productId, int accountId)
    {
        ...
    }

Note that we are not supposed to use [ODataRoute] attribute to customize it. Any thoughts?


Solution

  • Get operation with multiple parameters works just fine as usual, just need to call the service with named query string parameters. For example for the above Get operation the URL can be: http://localhost/myapp/odata/Products/?productId=1&accountId=2