Optional query string parameters in ASP.NET Web API

后端 未结 5 1168
粉色の甜心
粉色の甜心 2020-12-07 08:57

I need to implement the following WebAPI method:

/api/books?author=XXX&title=XXX&isbn=XXX&somethingelse=XXX&date=XXX

All of

5条回答
  •  生来不讨喜
    2020-12-07 09:10

    Use initial default values for all parameters like below

    public string GetFindBooks(string author="", string title="", string isbn="", string  somethingelse="", DateTime? date= null) 
    {
        // ...
    }
    

提交回复
热议问题