But i am getting the following error when i am trying to publish the content node.
Newtonsoft.Json.JsonReaderException: 'After parsing a value an
unexpected character was encountered: n. Path '[0].linkedElement',
line 1, position 98.'
Okay so solution was to make the Objects in C# and Serialize them using "JsonConvert.SerializeObject()". Rather than constructing a string which is prone to error. So the new code looks something like this
//create new element to be added
var lst = new List<Element>();
lst.Add(new Element()
{
name = node.Name,
udi = udi
});
//create new elemnt wrapper with propoer relationship to be added
var obj = new RootObject()
{
name = "Item " + (nestedResult.Count + 1),
ncContentTypeAlias = link.ncContentTypeAlias,
relationType = type,
linkedElement = JsonConvert.SerializeObject(lst)
};
nestedResult.Add(obj);
nestedStr = JsonConvert.SerializeObject(nestedResult);
if (isNew)
{
linkedContent.SetValue("linkedElements", nestedStr);
sender.SaveAndPublishWithStatus(linkedContent);
}
SetValue of a content node's property of type Neasted Content.
Hi,
I am trying to set the property of a content node. This property is of type Nested Content.
But i am getting the following error when i am trying to publish the content node.
Can anyone please help me find out the issue?
Okay so solution was to make the Objects in C# and Serialize them using
"JsonConvert.SerializeObject()"
. Rather than constructing a string which is prone to error. So the new code looks something like thisis working on a reply...