Add before! ReturnModel this line: [KnownType(typeof(FooFileModel))]
[KnownType(typeof(FooFileModel))]
[DataContract]
public class ReturnModel
{
[DataMember]
public string Name {get;set;}
[DataMember]
public List<IMyFileInterface> LatestFiles {get;set;}
}
The reason is that ReturnModel has a property of type that is an interface. That is not a run-time type and serialization is done using run-time types...
How it done? The underlying framework (that of data contract of WebAPI) try to load all the relevant run-time types BEFORE actual serialization. In the case of interface it can not be done...That line of KnownType instructs the framework to load also FooFileModel for later use...
If you intend to use more classes that implement the interface you will have to add a KnwonType lone for each...