I have a custom class with some additional data that i want to pass along with the comment. Here's the class structure :
public class AdditionalData { public AdditionalData() { Flags = new List<Flag>(); Likes = new List<Like>(); Commenter = string.Empty; }
public string Commenter { get; set; }
public IList<Flag> Flags { get; set; } public IList<Like> Likes { get; set; }
public bool IsMarkedAsOfficial { get; set; } public bool IsThreadedComment { get; set; }
public int CommentsCount { get; set; } public int FlagsCount { get; set; } // Needed for sorting public int LikesCount { get; set; } public string PageId { get; set; } public string PageTitle { get; set; } }
When I pass this to AddAsync() call on CommentService, I get the following exception :
EPiServer.Social.Common.ExtensionSerializationException: An error occurred while attempting to deserialize extension data. The extension class AdditionalData may not be suitable for successful serialization. ---> Newtonsoft.Json.JsonReaderException: Error reading string. Unexpected token: StartArray. Path 'Commenter'.
I looked into the internal code of Episerver.Social.Comments.Rest via dotpeek and pulled out the json serialization and deserialization logic and tried that directly in code and i see the data being parsed correctly via the serializer. I also googled the issue and most forums mention that if there is an array type field in the extenion object, that causes issues with deserialization and that it should be instead converted to a Dictionary<string, object>. I tried this for the 2 list properties above, but still get same exception.
So now not sure on the reason behind the exception.
Update : Upon more troubleshooting, I found that the save is successful. However after this new save, when I try to fetch the comments, that's when this deserialization error occurs. I also tested the same with items for which comments were previously saved in CMS 11 with Episerver.Social and was able to fetch those successfully with the same AdditionalData model. But as soon as I save a new comment now with CMS 12 on those items, the Get call fails on the deserialization error.
I'm also getting a similar deserialization error for Like and Flag calls.
Hi
I have a custom class with some additional data that i want to pass along with the comment. Here's the class structure :
public class AdditionalData
{
public AdditionalData()
{
Flags = new List<Flag>();
Likes = new List<Like>();
Commenter = string.Empty;
}
public string Commenter { get; set; }
public IList<Flag> Flags { get; set; }
public IList<Like> Likes { get; set; }
public bool IsMarkedAsOfficial { get; set; }
public bool IsThreadedComment { get; set; }
public int CommentsCount { get; set; }
public int FlagsCount { get; set; }
// Needed for sorting
public int LikesCount { get; set; }
public string PageId { get; set; }
public string PageTitle { get; set; }
}
When I pass this to AddAsync() call on CommentService, I get the following exception :
Composite<Comment, AdditionalData> savedComment = await _commentService.AddAsync(comment, additionalData);
EPiServer.Social.Common.ExtensionSerializationException: An error occurred while attempting to deserialize extension data. The extension class AdditionalData may not be suitable for successful serialization.
---> Newtonsoft.Json.JsonReaderException: Error reading string. Unexpected token: StartArray. Path 'Commenter'.
I looked into the internal code of Episerver.Social.Comments.Rest via dotpeek and pulled out the json serialization and deserialization logic and tried that directly in code and i see the data being parsed correctly via the serializer. I also googled the issue and most forums mention that if there is an array type field in the extenion object, that causes issues with deserialization and that it should be instead converted to a Dictionary<string, object>. I tried this for the 2 list properties above, but still get same exception.
So now not sure on the reason behind the exception.
Update : Upon more troubleshooting, I found that the save is successful. However after this new save, when I try to fetch the comments, that's when this deserialization error occurs. I also tested the same with items for which comments were previously saved in CMS 11 with Episerver.Social and was able to fetch those successfully with the same AdditionalData model. But as soon as I save a new comment now with CMS 12 on those items, the Get call fails on the deserialization error.
I'm also getting a similar deserialization error for Like and Flag calls.
Please advice.
Regards
Ritu