Tag Archives: WebAPI

How to capture a query string in a RESTful Get Request


I need to access the query parameter in the RESTful GET URL.


We overwrite our current GET method with another GET method that accepts a parameter. This parameter will be your query string. Then use LINQ to process your Enumerable object and return a filtered collection.

public IEnumerable<Product> Get(string queryString) { 
  var repository = new Repository(); 
  var products = repository.Retrieve(); 
  return products.Where(p => p.ProductId.Contains(queryString));