Asp.net

在郵遞員中發送實體模型

  • January 7, 2018

我創建了一個 Web API 並想用郵遞員檢查它,但不知道如何發布我的實體模型。總是模型為空

我用

$$ FromForm $$向我發送模型,但所有值均為空,並且在使用時$$ Frombody $$ 發送空

. your error is the CONTENT TYPE you're using to send the request.. 您選擇x-www-form-url-encoded(HTML 表格的格式).. 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..

所以in POSTMAN do:

1-選擇類型RAW

2-在出現的下拉列表中選擇application/json

3-paste your JSON in the Text Area

4-send it

希望對你有幫助!!

引用自:https://stackoverflow.com/questions/47754392