Search code examples
c#jsonsitecoresitecore8sitecore-mvc

Save Return Error in Sitecore Page Editor


I get an error when save a page in page editor.. Somehow when I edited the page from presentation > detail and display it in page editor it works fine.. The error logs is in below here..

ERROR After parsing a value an unexpected character was encountered: {. Path 'scLayout', line 38, position 85.  Exception: Newtonsoft.Json.JsonReaderException
Message: After parsing a value an unexpected character was encountered: {. Path 'scLayout', line 38, position 85.  Source: Newtonsoft.Json 
    at Newtonsoft.Json.JsonTextReader.ParsePostValue()
    at Newtonsoft.Json.JsonTextReader.ReadInternal()
    at Newtonsoft.Json.JsonTextReader.Read()
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) 
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) 
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
    at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
    at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
    at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
    at Sitecore.ExperienceEditor.Speak.Server.Requests.PipelineProcessorRequest`1.Process(RequestArgs requestArgs)

Any kind of thought or solution may help

Thanks


Solution

  • This is being caused by a confirmed bug in Sitecore. (reference # 84051 when opening a ticket)

    You can resolve this yourself, but I still recommend going through Sitecore so they can ensure that you have what you need.

    To solve, look at the /sitecore/shell/client/Sitecore/ExperienceEditor/ExperienceEditor.js file, on line 510 you will see that decodeURIComponent is being called twice.

    Updating it to only be called once like data: decodeURIComponent(JSON.stringify(commandContext)) will resolve the error.

    Likewise, a change is required in the /sitecore/shell/client/Sitecore/ExperienceEditor/RibbonPageCode.js file on line 24.

    Here, adding the decodeURIComponent method call is what fixes this file. So like this: ribbonUrl: decodeURIComponent(this.PageEditBar.get("url")),

    This probably addresses the Coveo issue as well, but my clients are not currently using Coveo, so I can't verify that.