I had my web api working fine, until a business rule obligates me to change a parameter from int to string. I knew that some bugs where expected but no this one:
[ResponseType(typeof(UserDTO))]
[HttpGet]
[Route("api/users/{id}")]
public IHttpActionResult GetUser(string id)
{
try
{
userValidator.secure(Request);
User user = userValidator.GetUser(id);
UserDTO userDTO = new UserDTO()
{
UserId = user.UserId,
Name = user.Name,
Admin = user.Admin,
Deleted = user.Deleted
};
return Ok(userDTO);
}
catch (NotExistException exception)
{
return ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.BadRequest, exception.Mymessage));
}
catch (System.Data.SqlClient.SqlException)
{
return ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "VecinosUY no se puede conectar a la base de datos (∩︵∩)"));
}
catch (Exception exception) {
return ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exception.Message));
}
}
HTTP get works fine if the string {id} doesn't contains a '.'
http://192.168.0.110:45455/api/users/facu works http://192.168.0.110:45455/api/users/facu.facu don't.
any work around for this problem ?