none
How can i populate an object using rest httppost? RRS feed

  • Question

  • I have this:

    [Route("api/[controller]")]
    public class OptoutClientController : Controller
    {
    HttpClient client = new HttpClient();

    [HttpPost]
    public IActionResult Unsubscribe([FromBody]OptOutCliente cliente)
    {
    return Ok();
    }

    }

    My model class

    public class OptOutCliente
    {
    public Int64 Cpf { get; set; }
    public String Email { get; set; }
    public String Telefone { get; set; }
    public String Bandeira { get; set; }
    public String Canal { get; set; }
    }

    Url Postman: http://localhost:55522/api/optoutclient

    Json Postman: 

    {
    "Cpf": "128907",
    "Email": "p@p.com.br"
    "Telefone": "971418418",
    "Bandeira": "CB",
    "Canal": "EML"
    }

    In the var cliente into Controller is Null. Why?

    Wednesday, June 20, 2018 8:35 PM

All replies

  • Show your postman config, that is likely where the issue is as your controller, model and json looks fine.
    Thursday, June 21, 2018 1:01 AM
  • Hi pnet,

    Please check the postman. Have you set it to json format? If no, please set.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, June 21, 2018 8:44 AM
    Moderator