I can’t email my Webapi

Asked

Viewed 47 times

0

I’m trying to create a function in my Webapi where I return information based on the email address I send, the problem is that the character "." breaks the route.

In case I did my action like this:

[AcceptVerbs("GET")]
[Route("Usuarios/GetUsuarioPorEmail/{email}")]
public IQueryable<Usuarios> GetUsuarioPorEmail(string email)

I tried to call it all these ways and none of it worked, http://localhost:11111/api/Usuarios/Getususporemail/[email protected] http://localhost:11111/api/Usuarios/Getususporemail/? [email protected] http://localhost:11111/api/Usuarios/Getususporemail/[email protected] http://localhost:11111/api/Usuarios/Getususporemail/[email protected] http://localhost:11111/api/Usuarios/Getususporemail/? [email protected]

But if I call it that, it works
http://localhost:11111/api/Usuarios/Getususporemail/test@testecom

Only there is no e-mail score.

2 answers

0


To avoid this scenario, include a bar at the end of the route. This implementation will delimit the parameter email between the two bars and will not consider it as part of the.

[Route("Usuarios/GetUsuarioPorEmail/{email}/")]
public IQueryable<Usuarios> GetUsuarioPorEmail(string email)

0

Do so:

[AcceptVerbs("GET")]
[Route("api/Usuarios/GetUsuarioPorEmail")]
public IQueryable<Usuarios> GetUsuarioPorEmail(string email)
{
}

and call in to test so:

http://localhost:80/api/Usuarios/[email protected]

result if you were to print the email:

inserir a descrição da imagem aqui

that is, a parameter get, of course after this receipt, an email validation is required to not have problems with invalid data.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.