0

I have this method receiving a post request and i'm not able to send a json

[HttpPost]
[Route("SalvarCliente")]
public HttpResponseMessage SalvarCliente(ClienteVM cliente)
{
 try
 {
 _clienteService.SalvarCliente(cliente);
 return new HttpResponseMessage(HttpStatusCode.OK)
 {
 Content = MessageJson("Cliente cadastrado com sucesso")
 };
 }
 catch (Exception ex)
 {
 return new HttpResponseMessage(HttpStatusCode.BadRequest);
 }
}

My class ClienteVM:

 public class ClienteVM
 {
 public int Id { get; set; }
 [Required]
 public string Nome { get; set; }
 [Required]
 public DateTime DataNascimento { get; set; }
 [Required]
 public DateTime DataInclusao { get; set; }
 public List<EnderecoVM> enderecos { get; set; }
 [Required]
 public byte Status { get; set; }
 }

which correct model of jason do i have to send? I'm testing by the postman you don't need to put the List EnderecoVm for a while.

I Try:

enter image description here

asked Aug 26, 2020 at 0:51
3
  • What JSON have you tried using in your requests? And what's the exact behavior are you seeing? Commented Aug 26, 2020 at 1:15
  • @devNull i posted print with my json and results Commented Aug 26, 2020 at 1:41
  • 1
    Change Text to Json in your postman. Commented Aug 26, 2020 at 1:42

1 Answer 1

3

Your postman should be like below: enter image description here

Result: enter image description here

answered Aug 26, 2020 at 1:46
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.