Skip to content
This repository was archived by the owner on Oct 31, 2021. It is now read-only.

Optional query parameters in webapi  #95

@pavelm

Description

@pavelm

I was converting a C# webapi project to F# using the F# ASP.NET templates. Everything is working great except optional query parameters. I keep getting this error

{
    "message": "The request is invalid.",
    "messageDetail": "The parameters dictionary contains an invalid entry for parameter 'start' for method 'System.Threading.Tasks.Task`1[System.Net.Http.HttpResponseMessage] GetVendorFiles(Int32, System.Nullable`1[System.DateTime])' in 'Thor.WebApi.VendorFilesController'. The dictionary contains a value of type 'System.Reflection.Missing', but the parameter requires a value of type 'System.Nullable`1[System.DateTime]'."
}

F# function signature:

        [<HttpGet; Route("")>]
        member x.GetVendorFiles( [<Optional; DefaultParameterValue(100)>] count, [<Optional; DefaultParameterValue(null)>] start : Nullable<DateTime> ) =

C# function signature:

        [HttpGet]
        [Route("")]
        public async Task<HttpResponseMessage> GetVendorFiles(int count = 100,DateTime? start = null)

Does any one know of any work arounds?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions