0

I'm trying to POST data to an API which should accept a List<UpdatePointHistory>. The size of the list is correct but the properties of the objects are blank.

public class UpdatePointHistory
{
    string Tree { get; set; }
    string FruitCount { get; set; }
    string Observations { get; set; }
    int PrivateId { get; set; }
}

public void Post([FromBody]List<UpdatePointHistory> updates)
{
    //Do some sort of auth for god sake
    Console.WriteLine("test");
}

The data I'm posting:

enter image description here

And the object returning from the API:

enter image description here

TomSelleck
  • 6,706
  • 22
  • 82
  • 151
  • 2
    All your properties are `private`. They need to be `public` so the model binder knows what to populate – Nkosi Jul 29 '17 at 23:57

1 Answers1

5

All your properties are private. They need to be public so the model binder knows what to populate and has access to them.

public class UpdatePointHistory
{
    public string Tree { get; set; }
    public string FruitCount { get; set; }
    public string Observations { get; set; }
    public int PrivateId { get; set; }
}
Nkosi
  • 235,767
  • 35
  • 427
  • 472