Reputation: 313
I have a GET
method that requires 2 parameters, my implementation is below. But I am getting an error. Is it the right way? At first I thought I can only pass one param, after I build the code I did not see an error, but when I consume the method in fiddler I am getting an error.
Suggestions please.
public class ProfessionalController : ApiController
{
public IProfessionalRepository professionalRepository;
public ListProfessionalController(IProfessionalRepository repo)
{
professionalRepository = repo;
}
[HttpGet]
public List<Professional> GetProfessionals(int companyId, string professionalName)
{
return professionalRepository.GetProfessionals(companyId, professionalName);
}
}
Upvotes: 0
Views: 71
Reputation: 8862
You need to call with a URI like: /api/Professional?companyId=10&professionalName=Prof.
The [HttpGet] is not necessary because GetProfessionals is already [HttpGet] by convention
Upvotes: 1