Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Edited Unassigned: XmlMediaTypeFormatter serialization failure [1561]

$
0
0
I have a simple API scenario where I am having problems with the XmlMediaTypeFormatter. When it tries to serialize my object I get the "The 'ObjectContent`1' type failed to serialize the response body for content type 'application/xml....." error.

The DTO is properly formed. For example, I can take the object returned in the WebAPI action, create a DataContractSeralizer and serialize just fine. - it only fails when the XmlMediaTypeFormatter does it. It is my understanding it is using the DataContractSeralizer under the covers also.

thanks,
stephen

Here is the DTO collection and model:
[CollectionDataContract(Name="DataGroups",Namespace="")]
[KnownType(typeof(DataGroupModel))]
public class DataGroupCollection : Collection<DataGroupModel>
{
public DataGroupCollection() : base(new List<DataGroupModel>()) { }

public DataGroupCollection(List<DataGroupModel> models) : base(models) { }
}

[DataContract(Name="DataGroup",Namespace="")]
public class DataGroupModel
{
public DataGroupModel() { }
[DataMember]
public int DataGroupId { get; set; }
[DataMember]
public string DataGroupName { get; set; }
[DataMember]
public string DisplayName { get; set; }
[DataMember]
public bool IsEnabled { get; set; }
[DataMember]
public bool IsPublic { get; set; }
[DataMember]
public bool IsSelfOnly { get; set; }
[DataMember]
public bool IsScoped { get; set; }
[DataMember]
public string ScopeProperty { get; set; }
[DataMember]
public string LastUpdatedBy { get; set; }
[DataMember]
public DateTime LastUpdatedDate { get; set; }
}

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>