{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/Mvc/issues/2762","labels_url":"https://api.github.com/repos/aspnet/Mvc/issues/2762/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/Mvc/issues/2762/comments","events_url":"https://api.github.com/repos/aspnet/Mvc/issues/2762/events","html_url":"https://github.com/aspnet/Mvc/issues/2762","id":91995937,"number":2762,"title":"[Suggestion] A New Attribute Needed For a simple parameter when doing \"Post\" by jQuery in Web Api","user":{"login":"MaleDong","id":6959154,"avatar_url":"https://avatars.githubusercontent.com/u/6959154?v=3","gravatar_id":"","url":"https://api.github.com/users/MaleDong","html_url":"https://github.com/MaleDong","followers_url":"https://api.github.com/users/MaleDong/followers","following_url":"https://api.github.com/users/MaleDong/following{/other_user}","gists_url":"https://api.github.com/users/MaleDong/gists{/gist_id}","starred_url":"https://api.github.com/users/MaleDong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MaleDong/subscriptions","organizations_url":"https://api.github.com/users/MaleDong/orgs","repos_url":"https://api.github.com/users/MaleDong/repos","events_url":"https://api.github.com/users/MaleDong/events{/privacy}","received_events_url":"https://api.github.com/users/MaleDong/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/aspnet/Mvc/labels/Model%20Binding","name":"Model Binding","color":"009800"},{"url":"https://api.github.com/repos/aspnet/Mvc/labels/wontfix","name":"wontfix","color":"ffffff"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-06-30T06:08:55Z","updated_at":"2015-07-20T23:14:54Z","closed_at":"2015-07-20T20:20:11Z","body":"Hello:\r\n   You see that if I let my jQuery call something like this:\r\n   ```\r\n   $.post(\"http://localhost:8080/……\",dataType:\"json\",data:{\"id\":\"1\"},……);\r\n   ```\r\n   And my actual Web Api defines:\r\n  ```\r\n   public int Post([FromBody] string id) {……}\r\n  ```\r\n  This is wrong. And I have to write something like this: \r\n  ```\r\n  $.post(\"http://localhost:8080/……\",dataType:\"json\",data:{\"\":\"1\"},……);\r\n ```\r\n  For a single parameter posted, I must leave the \"key\" empty. However for a complicated type defined in the server, I can combine a json object (something like {\"id\":\"1\",\"name\":\"Bill Gates\"}……). And this will be reflected into the object at the server side.\r\n\r\n  In fact, what we want is if I can write something like this below when passing a single value by Post at the server side:\r\n  ```\r\n   public int Post([FromBodyForSingle] string id)   //If I use something like this attribute, \"id\" will be readout directly through the \"Post\" method.\r\n```\r\n  And at the client side, I can write:\r\n  ```\r\n   $.post(\"http://localhost:8080/……\",dataType:\"json\",data:{\"id\":\"1\"},……);   //what if we can keep the \"id\" here to map the parameter name defined in my method, to make it empty is really an ugly thing....\r\n```\r\n  In my mind, the design would be better if:\r\n  1) \"FromBodyForSingleAttribute\" is a new attribute ONLY FOR a single variable passed by \"Post\" to a Web Api's method.\r\n  2) \"FromBodyAttribute\" will actually pass a json object by \"Post\" to a Web Api's method.\r\n  3) \"FromBodyAttribute\" can only be used once in a method parameters, \"FromBodyForSingleAttribute\" can be used many times.\r\n\r\nI'm not sure whether this situation also happens in FromUriAttribute?"},"comment":{"url":"https://api.github.com/repos/aspnet/Mvc/issues/comments/123085542","html_url":"https://github.com/aspnet/Mvc/issues/2762#issuecomment-123085542","issue_url":"https://api.github.com/repos/aspnet/Mvc/issues/2762","id":123085542,"user":{"login":"MaleDong","id":6959154,"avatar_url":"https://avatars.githubusercontent.com/u/6959154?v=3","gravatar_id":"","url":"https://api.github.com/users/MaleDong","html_url":"https://github.com/MaleDong","followers_url":"https://api.github.com/users/MaleDong/followers","following_url":"https://api.github.com/users/MaleDong/following{/other_user}","gists_url":"https://api.github.com/users/MaleDong/gists{/gist_id}","starred_url":"https://api.github.com/users/MaleDong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MaleDong/subscriptions","organizations_url":"https://api.github.com/users/MaleDong/orgs","repos_url":"https://api.github.com/users/MaleDong/repos","events_url":"https://api.github.com/users/MaleDong/events{/privacy}","received_events_url":"https://api.github.com/users/MaleDong/received_events","type":"User","site_admin":false},"created_at":"2015-07-20T23:14:54Z","updated_at":"2015-07-20T23:14:54Z","body":"@danroth27 : What do you mean by \"You can either define a type with an Id property and use that in your action method signature\"?"}}