1

I have this:

public class RuleController : ApiController { private readonly IRuleManager _ruleManager; // GET: api/Rule/guid [HttpGet] public IHttpActionResult GetRule(Guid id) { var rules = _ruleManager.GetRulesById(id); return Ok(rules); } [HttpGet] public async Task<IHttpActionResult> GetRuleNew(string locale, string pno, string modelYear) { // do cool stuff with my params } } 

my route config:

 config.Routes.MapHttpRoute("DefaultApiWithId", "Api/{controller}/{id}", new { id = RouteParameter.Optional }, new { id = @"\d+" }); config.Routes.MapHttpRoute("DefaultApiWithAction", "Api/{controller}/{action}"); config.Routes.MapHttpRoute("DefaultApiGet", "Api/{controller}", new { action = "Get" }, new { httpMethod = new HttpMethodConstraint(HttpMethod.Get) }); config.Routes.MapHttpRoute("DefaultApiPost", "Api/{controller}", new { action = "Post" }, new { httpMethod = new HttpMethodConstraint(HttpMethod.Post) }); config.Routes.MapHttpRoute( name: "ActionApi", routeTemplate: "api/{controller}/{action}/{id}", defaults: new { id = RouteParameter.Optional } 

calling my route:

https://localhost:44328/api/rule/GetRuleNew?locale=e?pno=2?modelYear=1 

I get:

"Message": "No HTTP resource was found that matches the request URI 'https://localhost:44328/api/rule/GetRuleNew?locale=e?pno=2?modelYear=1'.", "MessageDetail": "No action was found on the controller 'Rule' that matches the request."

What am I missing?

2
  • 3
    Have you tried using this instead ? https://localhost:44328/api/rule/GetRuleNew?locale=e&pno=2&modelYear=1 - using a & (instead of a ?) for the second and subsequent query parameters? Commented Jan 1, 2023 at 21:22
  • 1
    Wow this forum can sometimes really make you hate copy + paste. @marc_s kindly post this as an answer and thanks! Commented Jan 1, 2023 at 21:24

1 Answer 1

5

Have you tried using this instead ?

https://localhost:44328/api/rule/GetRuleNew?locale=e&pno=2&modelYear=1 

Basically just use a & (instead of a ?) for the second and subsequent query parameters...

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.