I have a GET-endpoint called GetPostalCodeXml
but it doesn't seem to ever get routed correctly
The method is in a class called WebServiceController
like so:
public class WebServiceController : ApiController
{
[HttpGet]
[ActionName("GetPostalCodeXml")]
public HttpResponseMessage GetPostalCodeXml(string postalCode)
{
return Request.CreateResponse(HttpStatusCode.OK, "ok");
}
}
In my WebApiConfig.cs
file the following code is run:
config.Routes.MapHttpRoute(
name: "GetPostalCodeXml",
routeTemplate: "WebService/GetPostalCodeXml",
defaults: new { controller = "WebService", action = "GetPostalCodeXml" }
);
I'm trying to make a GET-request to the endpoint with the following URL:
http://localhost:60736/WebService/GetPostalCodeXml?postalCode=73522
but it doesn't seem to ever work.
I have tried writing the route in different ways and changing the method name among other things. I have also tried reading on the Microsoft docs page on routing: https://learn.microsoft.com/en-us/aspnet/web-api/overview/web-api-routing-and-actions/routing-in-aspnet-web-api
I still do not understand what is wrong or what I can do to solve it. I feel like I am misunderstanding something basic. Please help