I have a post API method in my web API net core application thats has a Dto Class with the follow parameters:
public class ClassDto
{
public int Id { get; set; }
public Comunicacao Comunicacao { get; set; }
}
Comunicacao
Class:
public class Comunicacao
{
public int Id { get; set; }
public string Name { get; set; }
}
API Action(route has been setted correctly):
[HttpPost]
public async Task<IActionResult> Add([FromForm]ClassDto bannerDto, IFormFile imgDesktop)
{
try
{
if (ModelState.IsValid)
{
var result = await _banner.Add(classDto, imgDesktop);
return Ok(new { message = result.messageReturning, result.classDto });
}
else
{
return BadRequest(ModelState);
}
}
catch (Exception ex)
{
return BadRequest(ex.ToLogString(Environment.StackTrace));
}
}
So my question is, how can I send in Postman using FormData passing Comunicacao
Object Values? Because when I sent "Id", it works fine, but I can't find a way to send objects!
I cannot use FromBody
because as you all can see I'm sending a File as well.