I have a controller which contains certain kinds of methods. This controller is housed in a separate assembly. The idea being that other APIs can then opt in if they want to use this functionality as unbound functions.
The problem is that if I don't implement this functionality with the ODataConventionModelBuilder OData returns the following error:
System.AggregateException
HResult=0x80131500
Message=One or more errors occurred.
Source=<Cannot evaluate the exception source>
StackTrace:
<Cannot evaluate the exception stack trace>
Inner Exception 1:
InvalidOperationException: The path template 'TestFunction' on the action 'TestFunction' in controller 'OptInFunctions' is not a valid OData path template. Resource not found for the segment 'TestFunction'
If I remove the ODataRouteAttribute from the functions then OData does not return an error during startup, but a 404 when I want to call the function.
My controller with the opt-in methods looks something like this:
public class OptInFunctions : ODataController
{
[HttpGet]
[ODataRoute("TestFunction")]
public ActionResult<bool> TestFunction()
{
return Ok(true);
}
}
How can I make an OData unbound function opt-in?
User contributions licensed under CC BY-SA 3.0