0

I have defined the following action in FieldsController

[HttpGet]
[Route("api/farms/{farmIds}/{harvestYear:int}/fields")]
public IHttpActionResult Get(IntegerListParameter farmIds, int harvestYear)

The class IntegerListParameter is defined with ModelBinder

[ModelBinder(typeof(IntegerListModelBinder))]
public class IntegerListParameter : List<int>
{
}

My problem is that the WebApi.HelpPage is not recognizing Actions that have IntegerListParameter as a parameter.

I am using Microsoft.AspNet.WebApi.HelpPage" version="5.2.3

1 Answers1

0

I dont think that the model bindings are related to the Microsoft.AspNet.WebApi.HelpPage namespace. Its more about asp.net WebApi. I am not sure why you require passing the parameters from the uri, instead you can use http POST method and pass it through the body similar to the following:

[Route("api/farms/fields")]
[HttpPost]
public HttpResponseMessage Get(IntegerListParameter farmIds, int harvestYear)

But if u really want to pass the parameters through URI, then you can use the [FromUri] in the method/api signature just before "IntegerListParameter farmIds" or you can find similar posts as follows:

How to pass an array of integers to ASP.NET Web API?

Passing array of integers to webapi Method

http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx/

Community
  • 1
  • 1