c# - Calling POST method from API controller -
i have api controller named myfilescontroller.
in it, have method:
// post api/myfiles public void post([frombody]string value) { }
and here's how call fiddler:
post url: `http://localhost:58075/api/myfiles` ------------------------- request header: user-agent: fiddler host: localhost:58075 content-type: application/json content-length: 18 ------------- request body: {"value": "asjkfsf"}
the method gets called, value null. doing wrong?
create class corresponds json:
public class test { public string value{get; set;} public int id {get; set;} }
and change api-action:
// post api/myfiles public void post([frombody]test value) { }
if don't want that, change post-body:
"somevalue"
edit: added id post-payload. json should this:
{"value": "someval", "id": 1}
Comments
Post a Comment