I am new to REST services and am working on examples for the ASP.Net Web API. What I would like to do is extend this Get method:
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class ProductsController : ApiController
{
public IEnumerable<Product> GetAllProducts()
{
return new List<Product>
{
new Product() { Id = 1, Name = "Gizmo 1", Price = 1.99M },
new Product() { Id = 2, Name = "Gizmo 2", Price = 2.99M },
new Product() { Id = 3, Name = "Gizmo 3", Price = 3.99M }
};
} ...
Something where I send the list of products and all prices come back, in concept it will look like this:
public IEnumerable<Product> GetProducts(string[] ProductNames)
{
var pList = new List<Product>;
foreach (var s in ProductNames)
{
var LookedupPrice =
pList.Add(new Product() { Id = x, Name = s, Price = LookedUpPrice });
}
return pList;
}
Any ideas, and what would a REST call look like? I thought I needed to pass a JSON object, but I'm not really sure.
source
share