0

Hi all I am new in webapi and i am stuck in filter api hope get some solution from here

https://localhost/webservices/catalog/category/57/widgets/paginated?city=Gautam+Buddha+Nagar&pageNumber=0&pageSize=10&sort=relevance

for applying filtering https://localhost/webservices/catalog/category/57/widgets/paginated?city=Gautam+Buddha+Nagar&pageNumber=0&pageSize=10&gender=Female&product_form=Tablet&sort=relevance

If you see in my api it is same name of api but parameter is different in case how can i handle it.

1 Answer 1

1

You can take parameters as optional parameter. Just you have to remember you cant write necessary parameter after optional parameter -

[HttpGet] public IHttpActionResult ABC(string city = null, int? pageNumber = null, int? pageSize = null, string gender = null, string product_form = null, string sort = null){ }

Sign up to request clarification or add additional context in comments.

2 Comments

Can i handle it using public class abcPrameter{ public string city{ get; set;public int pageNumber { get; set; } ,etc}
Definitely you can do that. Take all parameters as a model (class) also you can validate the paramters using modelState.Isvalid property. Accept answer if it works for u.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.