I notice that FromBody is coming null and I do not know why.
This is my payload on Postman
{
"ChannelCode" : "TS",
"Name" : "Teste",
"Celphone" : "(11)999999999",
"Endpoint" : "www.teste.com.br",
"TokenLogin" : "1234567890",
"TokenLoginExpiration" : "2018-06-13T00:00:00.000Z",
"Active" : "true"
}
In this controller I get the request
[HttpPost]
[Authorize("Bearer")]
public async Task<IActionResult> Create([FromBody]ChannelCreateRequest channel)
{
if (channel == null) throw new WhatsAppApiException("Favor informar os dados do Canal!");
var result = await _channelCreateService.Process(new ChannelCreateCommand(channel.ChannelCode, channel.Name,
channel.Celphone, channel.Endpoint,
channel.TokenLogin,
channel.TokenLoginExpiration ,
channel.Active.GetValueOrDefault(true)));
return Ok(new ApiReturnItem<ChannelResult> { Item = result, Success = true });
}
everything will be saved in MongoDB
ChannelCreateRequest class
public class ChannelCreateRequest
{
[JsonProperty("codigo_canal")]
public string ChannelCode { get; set; }
[JsonProperty("nome")]
public string Name { get; set; }
[JsonProperty("celular")]
public string Celphone { get; set; }
[JsonProperty("url")]
public string Endpoint { get; set; }
//------ Remover-----------
[JsonProperty("token_canal")]
public string TokenLogin { get; set; }
[JsonProperty("token_canal_expiracao")]
public DateTime? TokenLoginExpiration { get; set; }
//--------Fim remover---------
[JsonProperty("ativo")]
public Boolean? Active { get; set; }
}
responding to Pagotti, here's the postman