I create a web API and want to check it with postman but don't know how to post my entity model.always model is null
I use [FromForm] send me model but all value is null and when use [Frombody] send null
Adding a Request body to the Post request- For this, select the Body tab. Now in the Body tab, select raw and select JSON as the format type from the drop-down menu, as shown in the image below. This is done because we need to send the request in the appropriate format that the server expects.
POST request to send JSON in a form (multipart/form-data)You need to enable this by clicking the three dots and enabling Content Type. This will allow you to create a multipart/form-data request with each part having a different content type. Notice how the part with JSON now has its own content type.
.your error is the CONTENT TYPE you're using to send the request
.. you choose x-www-form-url-encoded
(the format for the HTML FORMS) .. BUT if you want to use WebAPI and send your Entity in the PAYLOAD of yours request via REST .. you have to set CONTENT - TYPE as application/JSON
..
so in POSTMAN do:
1- choose type RAW
2- choose on the dropdown that appears application/json
3- paste your JSON in the Text Area
4- send it
Hope it helps you!!
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