I have an API which would return data using this format:
http://etr.azurewebsites.net/api/calculation/calculation?currency=eur&edition=standart&systems=50&version=5
I want to create an HttpActionResult which looks lie below:
public class CalculateController : ApiController
{
// GET: Calculate
[HttpGet]
public IHttpActionResult CalculatePrice([FromUri]string currency,
[FromUri]string edition = null,
[FromUri]int? systems = null,
[FromUri]string version = null)
{
//Code here
}
}
My RouteConfig class looks like:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { action = "Index", id = UrlParameter.Optional }
);
}
Also the Controller from where i get the data looks like this:
public class CalculationController : ApiController
{
[HttpGet]
public async Task<IHttpActionResult> Calculate(.._parameters_..)
{
//Code here...
}
}
How could i make a request to get the data from the URL i want?