[X] Page Transformation: Error during the use of page transformation from PnP PowerShell
Expected or Desired Behavior
ConvertTo-PnPPage should modernize the web part pages having script editor web parts. It should convert classic OOB script editor web parts to configured react script editor web part.
PnP PowerShell Online Version Details:
Name: SharePointPnPPowerShellOnline
Version: 3.29.2101.0
Observed Behavior
Getting the below error while trying to modernize the page with script editor web part:
_'0x0D' is invalid within a JSON string. The string should be correctly escaped. Path: $ | LineNumber: 0 | BytePositionInLine: 317. at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& readStack, JsonReaderException ex)
at System.Text.Json.JsonSerializer.ReadCore(JsonSerializerOptions options, Utf8JsonReader& reader, ReadStack& readStack)
at System.Text.Json.JsonSerializer.ReadCore(Type returnType, JsonSerializerOptions options, Utf8JsonReader& reader)
at System.Text.Json.JsonSerializer.Deserialize(String json, Type returnType, JsonSerializerOptions options)
at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
at PnP.Core.Model.SharePoint.PageWebPart.setPropertiesJson(String value)
at PnP.Framework.Modernization.Transform.ContentTransformator.Transform(List`1 webParts)
at PnP.Framework.Modernization.Transform.PageTransformator.Transform(PageTransformationInformation pageTransformationInformation)
It is working fine if I remove the newline character from the script. But for us it is a lot of pages and will not be feasible to manually remove the newline character from each script. Is there any alternative solution to fix this issues for all of the pages.
Steps to Reproduce
Install the react-script editor web part to the app catalog from the link https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-script-editor
Create a web part page in a classic SharePoint site, add OOB script editor web part and add the below sample script in the code snippet of the script editor web part.
Sample Script:
`
My First JavaScript
`
Then use the below script to modernize the page with the switch -UseCommunityScriptEditor:
ConvertTo-PnPPage -Identity $page.FieldValues["ID"] `
-Overwrite `
-DisablePageComments `
-AddTableListImageAsImageWebPart: $false `
-ClearCache `
-SkipItemLevelPermissionCopyToClientSidePage `
-TakeSourcePageName:$TakeSourcePageName `
-LogType File `
-LogFolder $LogOutputFolder `
-LogVerbose `
-LogSkipFlush `
-KeepPageCreationModificationInformation `
-UseCommunityScriptEditor `
-CopyPageMetadata `
I am also seeing this and can't locate the offending web part to even know how to troubleshoot. Several pages have web parts that get transformed but at least one fails with this error.
Problem Area
[X] Page Transformation: Error during the use of page transformation from PnP PowerShell
Expected or Desired Behavior
ConvertTo-PnPPage should modernize the web part pages having script editor web parts. It should convert classic OOB script editor web parts to configured react script editor web part.
PnP PowerShell Online Version Details: Name: SharePointPnPPowerShellOnline
Version: 3.29.2101.0
Observed Behavior
Getting the below error while trying to modernize the page with script editor web part:
_'0x0D' is invalid within a JSON string. The string should be correctly escaped. Path: $ | LineNumber: 0 | BytePositionInLine: 317. at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& readStack, JsonReaderException ex) at System.Text.Json.JsonSerializer.ReadCore(JsonSerializerOptions options, Utf8JsonReader& reader, ReadStack& readStack) at System.Text.Json.JsonSerializer.ReadCore(Type returnType, JsonSerializerOptions options, Utf8JsonReader& reader) at System.Text.Json.JsonSerializer.Deserialize(String json, Type returnType, JsonSerializerOptions options) at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options) at PnP.Core.Model.SharePoint.PageWebPart.setPropertiesJson(String value) at PnP.Framework.Modernization.Transform.ContentTransformator.Transform(List`1 webParts) at PnP.Framework.Modernization.Transform.PageTransformator.Transform(PageTransformationInformation pageTransformationInformation)
Page Transformation Settings
Transformation Operation Details
Note: It is similar to issue https://github.com/pnp/modernization/issues/606
It is working fine if I remove the newline character from the script. But for us it is a lot of pages and will not be feasible to manually remove the newline character from each script. Is there any alternative solution to fix this issues for all of the pages.
Steps to Reproduce
Install the react-script editor web part to the app catalog from the link https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-script-editor Create a web part page in a classic SharePoint site, add OOB script editor web part and add the below sample script in the code snippet of the script editor web part.
Sample Script: `
My First JavaScript