I'm trying to build a get action in WebAPI (C#) which will respond to the following:
http://{host}/api/Callback/CompleteFlow/{MyId}/{dynamic parameters I have no control on}
For example: http://{host}/api/Callback/CompleteFlow/7?param1=abc¶m2=def
and also: http://{host}/api/Callback/CompleteFlow/7
I've created an action with the following signature:
[HttpGet]
public HttpResponseMessage CompleteFlow(int MyId, string requestParams)
{
}
and added specific routing:
config.Routes.MapHttpRoute(
name: "Callback",
routeTemplate: "api/Callback/CompleteFlow/{MyId}/{*requestParams}",
defaults: new { controller = "Callback", action = "CompleteFlow", requestParams = RouteParameter.Optional });
I'm getting MyId parameter but not the dynamic parameters into the requestParams parameter within the action (I'm expecting to get requestParams=param1=abc¶m2=def, but gets null instead).
What am I missing here?
Thanks, Nir.