Return query with more than 1 parameter in Webapi

Asked

Viewed 473 times

-5

I have the code below, how would be the correct route? How can I test the call

        //http://localhost:1608/api/ApiCidade/consulta/clienteLoginSenha/
        [HttpGet]
       // [Route("consulta/clienteLoginSenha/{email:long}/{senha:long}")]
        [Route("consulta/clienteLoginSenha/email{email}/senha/{senha}")]
        public HttpResponseMessage ClientePorLoginSenha(string email, string senha)
        {
            try
            {
                var tCliente = new ClienteAplicacao();
                var listarDeClientes = tCliente.ListarPorLoginSenha(email,senha);
                return Request.CreateResponse(HttpStatusCode.OK, listarDeClientes.ToArray());
            }
            catch (Exception ex)
            {

                return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
            }
        }
  • How do you want the route to be? What error are you currently encountering?

  • I made a test with the two routes that I am putting in question, the two generates an error

  • Which error returns? tries to detail more

  • the route looks like this : [Route("query/clientLoginSenha/{email}/{password}")] is for testing : http://localhost:1608/api/Apicity/query/clientLoginSend/[email protected]/test

1 answer

0


The answer:

a rota ficou assim : 
[Route("consulta/clienteLoginSenha/{email}/{senha}")]
é para testar : http://localhost:1608/api/ApiCidade/consulta/clienteLoginSenha/[email protected]/teste

Browser other questions tagged

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