0

I am using MediatR and Entity Framework Core and I have a post controller action

[HttpPost]
public async Task<ActionResult<User>> RegisterUser(RegisterUserCommand request)
{
    var response = await _mediator.Send(request);
    if (!response.IsSuccess)
    {
        return BadRequest(response.Error);
    }

    return Ok(response.Result);
}

Where RegisterUserCommand is defined as

public class RegisterUserCommand : IPreprocessedRequest<ICommandResult>
{
    public string Email { get; set; } = string.Empty;

    [ValidateNever]
    public string? Error { get; set; }
}

When I try to send a POST request from Postman it gives me a 415 error.

If it is necessary I can post the handler class

Ivan Stoev
  • 195,425
  • 15
  • 312
  • 343
Asker
  • 97
  • 1
  • 11

1 Answers1

2

Change header in postman to app json, double check your request headers