I created a WEB API using a MySQL . The table contains data on the serial numbers of the counter, which correspond to the signal strength values ββand the date of the time at which the signal strength arrives. So far, I manage to get the data by sending the serial number of the counter.
Now I will also send him a date time parameter. But this does not work for me. Here is what I did.
public HttpResponseMessage GetByMsn(string msn, DateTime dt) { try { return Request.CreateResponse(HttpStatusCode.Found, medEntitites.tj_xhqd.Where(m=> m.msn == msn).Where(a=> a.date_time < dt )); } catch (Exception ex) { return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex); } }
WebApiConfig file includes
config.Routes.MapHttpRoute( name: "GetByMsn", routeTemplate: "api/{controller}/{action}/{msn}/{dt}", defaults: null, constraints: new { msn = @"^[0-9]+$" , dt = @"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$" } );
After that, I pass the URL as http://localhost:14909/api/meters/GetByMsn/000029000033/2017-10-06T07:52:27
The error I get is A potentially dangerous Request.Path value was detected from the client (:).
For this, I also looked for solutions, but could not find the right one. I also replaced : with a date, but still it does not work for me
Update 1
When transferring only the dates 2017-10-06 it works for me, but when I add it over time, it does not work
For a quick check, I checked this question , but still can't solve the problem.
I need to miss something I don't know
Any help would be greatly appreciated.
rest mysql visual-studio-2015 datetime-format asp.net-web-api2
faisal1208 Oct 10 '17 at 6:48 2017-10-10 06:48
source share