Save Return Error in Sitecore Page Editor

I get an error while saving a page in the page editor. Somehow, when I edited the page from the presentation> in detail and displayed it in the page editor, it works fine. Error logs are here below.

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 thoughts or solutions can help.

thanks

+5
source share
3 answers

This is caused by a confirmed error in Sitecore. (link # 84051 when opening a ticket)

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

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

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

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

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

This probably also applies to the Coveo issue, but my clients are not currently using Coveo, so I cannot verify this.

+6
source

This post has been fixed for me. Note. I am using Sitecore 8.2 Update 2

My mistake:

After parsing a value an unexpected character was encountered: {. Path 'scLayout', line 1, position 2246.

http://jockstothecore.com/experience-editor-error/

 postServerRequest: function (requestType, commandContext, handler, async) { function normalizeDeviceProp(d) { if (typeof(d) !== "object") throw new Error("Unexpected presentation details XML: cannot find device property"); if (d instanceof Array) return d; var normalized = []; normalized.push(d); return normalized; } var token = $('input[name="__RequestVerificationToken"]').val(); // Custom Brainjocks code to fix Experience Editor error. var ajaxData = unescape(JSON.stringify(commandContext)); if (commandContext && commandContext.scLayout) { var obj = JSON.parse(commandContext.scLayout); if (obj && obj.r) { normalizeDeviceProp(obj.rd).forEach(function (d) { if (dr instanceof Array) { drforEach(function (r) { var val = r["@par"]; if (val && val.length > 0) { ajaxData = ajaxData.replace(unescape(val), val); } }); } }); } } jQuery.ajax({ url: "/-/speak/request/v1/expeditor/" + requestType, data: { __RequestVerificationToken: token, data: ajaxData }, success: handler, type: "POST", async: async != undefined ? async : false }); } 
+2
source

Check the contents of all saved fields. The Experience / Page editor must serialize everything into a json object in order to invoke its own internal APIs. A stray character may occur in one of your fields that disables the json serializer. I came across this when the content editor copied and pasted their contents from another place.

0
source

Source: https://habr.com/ru/post/1241574/


All Articles