Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

send entity model in postman

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

like image 454
Majid Dehnamaki Avatar asked Dec 11 '17 13:12

Majid Dehnamaki


People also ask

How do I add body data to my Postman?

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.

How can I send form data and JSON data in Postman?

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.


1 Answers

.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!!

like image 154
federico scamuzzi Avatar answered Sep 26 '22 04:09

federico scamuzzi