Web Api asp.net mvc have any data limits reported on Route?

0

I have a web api, I'm trying to do an insert in a user registry, but I noticed that the number of parameters has a limit. If I try to add one more parameter it generates an error:

      [HttpPost]
        [Route("consulta/InseriUsuario/{apiKey}/{userKey}/{idpais}/{idioma}/{idperfil}/{nomecompleto}/{sobrenome}/{titulocareira}/{ladoequipe}/{patrocinador}/{email}/{celular}/{cidade}/{endereco}/{cep}/{uf}/{numero}/{complemento}/{senha}/{login}/{nomeequipe}/{ddi_fone}/{ddd_fone}/{telefone}/{ddi_whtas}/{ddd_whats}/{whatsapp}/{skype}/{twitter}")]

        public  HttpResponseMessage InseriUsuario(string apiKey, string userKey, int IDPAIS, int IDIDIOMA, int IDPERFIL, string NOMECOMPLETO, string SOBRENOME,
                                 string TITULOCARREIRA, string LADOEQUIPE, string PATROCINADOR, string EMAIL,
                                 string CELULAR, string CIDADE, string ENDERECO, string CEP,
                                 string UF, string NUMERO, string COMPLEMENTO, string SENHA,
                                 string LOGIN, string NOMEEQUIPE, string DDI_FONE, string DDD_FONE,
                                 string TELEFONE, string DDI_WHATS, string DDD_WHATS, string WHATSAPP,
                                 string SKYPE, string TWITTER, string FACEBOOK, string URLCADASTRO,
                                 string URLCONFERENCIA, string HORACONFERENCIA, string URLCONFERENCIAGRAVADA, string URLLOJAVIRTUAL,
                                 string TITULODEPOIMENTO, string DESCRICAODEPOIMENTO, string IMAGEMPERFIL)
        {

            try
            {
                var tTabela = new UsuarioAplicacao();
                tTabela.InseriUsuario(apiKey, userKey, IDPAIS, IDIDIOMA, IDPERFIL, NOMECOMPLETO, SOBRENOME, TITULOCARREIRA, LADOEQUIPE,
                                        PATROCINADOR, EMAIL, CELULAR, CIDADE, ENDERECO, CEP, UF, NUMERO, COMPLEMENTO, SENHA, LOGIN, NOMEEQUIPE,
                                        DDI_FONE, DDD_FONE, TELEFONE, DDD_WHATS, DDD_WHATS, WHATSAPP, SKYPE, TWITTER, FACEBOOK, URLCADASTRO,
                                        URLCONFERENCIA, HORACONFERENCIA, URLCONFERENCIAGRAVADA, URLLOJAVIRTUAL, TITULODEPOIMENTO,
                                        DESCRICAODEPOIMENTO, IMAGEMPERFIL);

                return Request.CreateResponse(HttpStatusCode.OK, tTabela);
            }
            catch (Exception ex)
            {

                return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
            }
        }

    
asked by anonymous 28.10.2016 / 03:15

1 answer

0

object

public class ClientViewModelRegister
{      
    public string Name { get; set; }
    public string Email { get; set; }
}



        [HttpPost]
        [Route("register")]
        public HttpResponseMessage Register(ClientViewModelRegister model)
        {

            try
            {
                if (ModelState.IsValid)
                {
                    Client client = new Client()
                    {
                        Name = model.Name,
                        Email = model.Email,
                        DateRegister = DateTime.Today                                                  
                    };

                    _AppClient.Insert(client);

                    return Request.CreateResponse(HttpStatusCode.OK, "Register Successfully");

                }
                else
                {
                    return ErrorModel();
                }
            }
            catch (Exception e)
            {

                return Request.CreateResponse(HttpStatusCode.BadRequest, e.Message);
            }

        }

first we have object according to the controller you have to do this way where you are property, you put everything in object that you want to receive as a parameter so it becomes simpler, I'll leave a project link below for you to have as an example. link

obs: any call that makes a name when sending must be equal to the property if it will not receive a null value.

eg if I send a name object must have property public string name {get; set;}

    
28.10.2016 / 13:53