0

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); } } 
2
  • 1
    Yes, you can have 2 parameters. Your code looks fine at first glance. How are you calling it? Commented Apr 15, 2014 at 21:13
  • Please specify what error you are getting. Commented Apr 16, 2014 at 0:38

1 Answer 1

1

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

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.