asp.net web api - Ajax Web-Api optional parameter null issue. -
ajax webapi when parameter null or blank 400 bad reuqsest occurs. solution needed asap.
http://{parenturl}/api/buildtypewebapi/getbuildtypelist?currpage=1&pagesize=10&buildtypename=
here buildtypename optional parameter when there not search parameter passed how reduce 400 error.
//controller
public httpresponsemessage getbuildtypelist(int currpage, int pagesize, string buildtypename = "") { }
here issue buildtype.
help one.
regards
you need change way request made. either complete request string adding =""
end, or leave out buildtypename
parameter when empty.
so either of these 2 cases:
/api/buildtypewebapi/getbuildtypelist?currpage=1&pagesize=10&buildtypename=""
/api/buildtypewebapi/getbuildtypelist?currpage=1&pagesize=10
this way, web api knows want buildtypename parameter. in case incomplete request.
Comments
Post a Comment