문제

Ajax webapi when parameter is null or blank then 400 bad reuqsest occurs. solution needed asap.

http://{parenturl}/api/BuildTypeWebApi/GetBuildTypeList?CurrPage=1&PageSize=10&BuildTypeName=

here BuildTypeName is optional parameter when there is not search parameter passed how to reduce 400 error.

//controller

public HttpResponseMessage GetBuildTypeList(int CurrPage, int PageSize, string BuildTypeName = "")
{
}

here issue with only BuildType.

help some one.

Regards

도움이 되었습니까?

해결책

You need to change the way the request is made. Either complete your request string by adding ="" to the end, or leave out the BuildTypeName parameter when it is empty.

So you get either of these two cases:

/api/BuildTypeWebApi/GetBuildTypeList?CurrPage=1&PageSize=10&BuildTypeName=""

/api/BuildTypeWebApi/GetBuildTypeList?CurrPage=1&PageSize=10

This way, Web API actually knows what you want to do with the BuildTypeName parameter. In your case it was an incomplete request.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top