Reputation: 872
I am new to Postman. The Get queries work fine but I can't send Post. I work with Net .Core. In my controller I have:
[HttpPost]
public IActionResult Post(Order model)
{
return Ok();
}
I am getting error 400 if I am trying to add Content-Type manually or 415 if I leave it as is and just set JSON.
Upvotes: 0
Views: 1160
Reputation: 25350
That's because your payload is sent as querystring
instead of appliation/json
.
Params
becomes querystring
in the URLBody
. It's likely that you didn't specify a body. In other words, the Body
is empty.It seems that you want to send a payload of application/JSON
to server. If that's the case, make sure:
Content-Type: application/json
in Headers
Add a well-formatted JSON payload in the Body
Tab:
By the way,
[ApiController]
expects a payload of application/json
by default, which means the clients need send a well-formatted JSON with header of application/json
.[ApiController]
, the body payload by default should be a form. In most cases they'll be application/x-www-form-urlencoded
. PostMan allows us to sends payload of different Content-Types. Please do check the related radio button when there's a need.
Upvotes: 1