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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -