I have developed web service using ASP.NET Web API for my application. Find code to access data's from WEP API
namespace ProjectTrackingServices.Controllers
{
[EnableCors(origins: "*", headers: "*", methods: "*")]
public class PTEmployeesController : ApiController
{
[Route("api/ptemployees/{name:alpha}")]
public HttpResponseMessage Get(string name)
{
var employees = EmployeesRepository.SearchEmployeesByName(name);
HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, employees);
return response;
}
}
}
I can filter specific employee data's using their name , which has without space in name string. ex: URL: http://localhost:55487/api/ptemployees/john
When i try to filter the employees with full name[ has spaces] by url ex: Url: " http://localhost:55487/api/ptemployees/john markus " Error will return "NetworkError: 400 Bad Request - http://localhost:55487/api/ptemployees/john%20m"
So anyone help how to pass url parameter with spaces and return success status in WEP API.