I just started using web api and I was wondering if the parameter value is supposed to be null if you don't have any query parameters.
For example, I have this model:
[DataContract]
public class GetBooksRequest
{
public int? BookLimit { get; set; }
}
Used in the following action
[HttpGet]
[Route("api/books")]
public IHttpActionResult Get([FromUri]GetBooksRequest request) {
// request is null
}
Is parameter value supposed to be null if I hit api/books?.
It hits my endpoint, but parameter is null. If I do api/books?booklimit=1, then parameter is not null and the BookLimit property is set to 1 as expected.
I just wasn't sure if that's the way web api works.