Response code 400 in Asp.net core 3.1 version

Ketan Patil 21 Reputation points
2021-06-22T14:47:28.147+00:00

I am getting 400 response code in Asp.net core web api on POST Save method Controller/Save ,i just recently upgraded .net core web api version to 3.1

        [HttpPost]
        [ContentValidation("Shell.xsd")]
        [Authorize(Policy = "Test")]
        public async Task<IActionResult> Save([FromBody]Shell shell)
        {

        }
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,596 questions
ASP.NET API
ASP.NET API
ASP.NET: A set of technologies in the .NET Framework for building web applications and XML web services.API: A software intermediary that allows two applications to interact with each other.
341 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 54,731 Reputation points
    2021-06-22T14:51:47.327+00:00

    We're going to need more information. What does the actual request look like being sent over the wire?

    There is a ContentValidation attribute on your action that I've never seen before. If it does validation against XML then try commenting it out temporarily. Personally I would be worried about this because API media formats should not be part of the action implementation. Furthermore the binder is going to fix all this up anyway so you should just validate the model.

    Does your model have validation? If so what does it look like?


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.