Home > Enterprise >  Post with Custom Object parameter not getting data
Post with Custom Object parameter not getting data

Time:02-23

I am using the Post function from the Visual Studio template as seen below, but I've modified it to receive a custom object Testing. When I use Fiddler to Post I am able to step into the code, but both id and name inside of the Testing object are null. Am I misunderstanding something as to why the don't have the values I am passing in through the Request Body?

public void Post([FromBody] Testing value)
{
    var a = value;
}

public class Testing
{
    string id;
    string name;
}

enter image description here

CodePudding user response:

You might use public property instead of `private field for your model.

public class Testing
{
    public string id {get;set;}
    public string name {get;set;}
}
  • Related