0

FYI, I have no custom routing, no usage of MapHttpRoute.

My Web API controller is as follows:

[RoutePrefix("api/stat")] public class StatController : ApiController 

In that controller I has these methods:

 [Route("{statType}")] public StatState GetCurrentStat(string statType, UserInfo userInfo) [Route("getAllAccount")] public Dictionary<string, StatState> GetAllAccountCurrentStat(UserInfo userInfo) [Route("getScoreHistory")] public StatHistory GetStatAccountScoreHistory(string statType, UserInfo userInfo) 

An HTTP GET call with this url: /api/stat/getAllAccount correctly maps to:

 [Route("getAllAccount")] public Dictionary<string, StatState> GetAllAccountCurrentStat(UserInfo userInfo) 

An HTTP GET call with this url: /api/stat/getScoreHistory INCORRECTLY maps to:

[Route("{statType}")] public StatState GetCurrentStat(string statType, UserInfo userInfo) 

How do I get /api/stat/getScoreHistory to map correctly and why does /api/stat/getAllAccount do as I expected it to?

1 Answer 1

1

The presence of the statType parameter in the definition of your third endpoint but not in your /api/stat/getScoreHistory URL means that the first of your three endpoints is the best match.

You need to remove the extraneous statType parameter from your last endpoint:

[Route("getScoreHistory")] public StatHistory GetStatAccountScoreHistory(UserInfo userInfo) 
Sign up to request clarification or add additional context in comments.

1 Comment

That did it!, I should have noticed!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.