我创建了一个Web API并希望用postman检查它,但不知道如何发布我的实体模型。所以模型为null
我使用[FromForm]发送给我模型,但是所有值都为null并且当使用[Frombody]时 发送null
答案 0 :(得分:6)
。your error is the CONTENT TYPE you're using to send the request
..您选择x-www-form-url-encoded
(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
..
所以in POSTMAN do:
1-选择类型RAW
2-选择显示application/json
3- paste your JSON in the Text Area
4- send it
希望它可以帮到你!!