c# - Web API parameter is always null -
i have following method in web api:
[acceptverbs("post")] public bool movefile([frombody] fileusermodel model) { if (model.domain == "abc") { return true; } return false; }
the fileusermodel
defined as:
public class fileusermodel { public string domain { get; set; } public string username { get; set; } public string password { get; set; } public string filename { get; set; } }
i'm trying call through fiddler whenever model set null. in fiddler i've sent composer use post
, url there , correct debugger in visual studio breaks when called. request i've setup as:
user-agent: fiddler host: localhost:46992 content-length: 127 content-type: application/json
the request body as:
"{ "domain": "dcas" "username": "sample string 2", "password": "sample string 3", "filename": "sample string 4" }"
but whenever run composer when debugger hits breakpoint shows model null.
the problem have posting json data surrounding double quotes. remove them , should work.
also fix missing comma:
{ "domain": "dcas", "username": "sample string 2", "password": "sample string 3", "filename": "sample string 4" }
Comments
Post a Comment