I use api controller in ASP.net web API and i need to pass value to post method by [FromBody] type..
[HttpPost] public HttpResponseMessage Post( [FromBody]string name) { .... }
i use Postman plugin but when send to post method value of name always is null.. follow this image:
and in Post methods :
why this happend?!
If you need to get multiple values from the request body, define a complex type. But still the value of email is NULL . The JavaScript code is part of generic method we use, so that's why the content-type is set to application/json; charset=utf-8 .
Right-click selected text, and choose EncodeURIComponent to manually encode a parameter value. To send a path parameter, enter the parameter name into the URL field, after a colon, for example :id . When you enter a path parameter, Postman will populate it in the Params tab, where you can also edit it.
Simply add parameterName = null in your route parameter. Another option is add an overload. Have 2 function names receive different parameters. @kanika it's a precaution because there might be something yet to be setup in your controller and your controller is not accepting the parameters being sent.
Post the string with raw json, and do not forget the double quotation marks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With