I want to be able to pass object with multi-type list to web api call, but it seems that if I don't explicitly state properties, web api just ignores the data.
Below you can see, that an Interface is used as placeholder to allow multi-type lists in C#, but it seems that wehn passing json string to web api, it does not map the values due to DTO mismatch.
Icoming DTO:
public class ValueCheckTestDto
{
public List<IValueCheckGroup> Groups { get; set; }
}
Used classes and interfaces
public class ValueCheck : IValueCheckGroup
{
public ValueCheckOperators Operator { get; set; }
public List<IValueCheckGroup> ValueCheckGroups{ get; set; }
}
public class ValueCheckExpression : IValueCheckGroup
{
public int AsocDataFieldID { get; set; }
public string Operand { get; set; }
}
public interface IValueCheckGroup
{
}
Example JSON
{
Groups: [{
AsocDataFieldID: 3,
Operand: "2323"
}]
}
A bit more complex version of JSON string
{
Groups: [{
Operator: "OR",
ValueCheckGroups: [{
Operator: "OR",
ValueCheckGroups: [{
AsocDataFieldID: 3,
Operand: "test string"
}]
},{
Operator: "AND",
ValueCheckGroups: [{
AsocDataFieldID: 4,
Operand: "test string 2"
}]
}]
}]
}