0
I’m using the Postman: Error: "Undefined object reference for an object instance."
I have the Controller Code:
//http://localhost:1608/api/ApiGuiaCidade/cadastrar/cliente
//"Referência de objeto não definida para uma instância de um objeto."
[HttpPost]
[Route("cadastrar/cliente/")]
public HttpResponseMessage PostCadastro(Cliente cliente)
{
try
{
var tCliente = new ClienteAplicacao();
tCliente.Inseri(cliente);
return Request.CreateResponse(HttpStatusCode.OK, "Cadastro do cliente" + cliente.Nome + "realizado.");
}
catch (Exception ex )
{
return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
}
}
Have of the application:
public void Inseri(Cliente cliente)
{
var strQuery = "";
strQuery += "INSERT INTO CLIENTES (NOME, DATA_NASCIMENTO,EMAIL, SENHA)";
strQuery += string.Format(" VALUES ('{0}','{1}','{2}','{3}' )", cliente.Nome, cliente.DataNascimento, cliente.Email, cliente.senha);
using (contexto = new Contexto())
{
contexto.ExecutaComando(strQuery);
}
}
How are you firing the payload by Postman? You can take a picture of the screen?
– Leonel Sanches da Silva
Why do you put syntax highlighting as html?
– Jéf Bueno
I can do the editing by adding a photo, but the error now is: Could not get any Response This seems to be like an error Connecting to http://localhost:1608/api/Apiguiacity/register/client. The Response status was 0. Check out the W3C Xmlhttprequest Level 2 spec for more Details about when this Happens.
– Harry