I am using OData V4 and have an unbound method registered this way:
var getByHint = builder.Function("GetByHint"); getByHint.Parameter<string>("Hint"); getByHint.ReturnsCollectionFromEntitySet<SubCategory>("SubCategories");
This is the corresponding method in the controller:
[HttpPost] [ODataRoute("GetByHint")] public async Task<IHttpActionResult> GetByHint(ODataActionParameters parameters) { ... }
Then I send a POST request ( by using Fiddler):
http://localhost:57637/GetByHint
with the below headers:
Content-Type: application/json Host: localhost:57637 Content-Length: 15
and the following body:
{"Hint":"test"}
The controller's method is being called but the parameters is always null, I enabled Web API tracing, this is the output:
iisexpress.exe Information: 0 : Request, Method=POST, Url=http://localhost:57637/GetByHint, Message='http://localhost:57637/GetByHint' iisexpress.exe Information: 0 : Message='SubCategories', Operation=DefaultHttpControllerSelector.SelectController 'iisexpress.exe' (CLR v4.0.30319: /LM/W3SVC/2/ROOT-1-130844429306720269): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. iisexpress.exe Information: 0 : Message='WebService.Controllers.SubCategoriesController', Operation=DefaultHttpControllerActivator.Create iisexpress.exe Information: 0 : Message='WebService.Controllers.SubCategoriesController', Operation=HttpControllerDescriptor.CreateController iisexpress.exe Information: 0 : Message='Selected action 'GetByHint(ODataActionParameters parameters)'', Operation=ApiControllerActionSelector.SelectAction iisexpress.exe Information: 0 : Message='Will use same 'FormUrlEncodedMediaTypeFormatter' formatter', Operation=FormUrlEncodedMediaTypeFormatter.GetPerRequestFormatterInstance iisexpress.exe Information: 0 : Message='Will use same 'JQueryMvcFormUrlEncodedFormatter' formatter', Operation=JQueryMvcFormUrlEncodedFormatter.GetPerRequestFormatterInstance iisexpress.exe Information: 0 : Message='Model state is invalid. parameters: ', Operation=NonValidatingParameterBinding.ExecuteBindingAsync iisexpress.exe Information: 0 : Message='Model state is invalid. parameters: ', Operation=HttpActionBinding.ExecuteBindingAsync
Can you help me figure out why parameters is null?