Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetPagesAsync throwing an error #1131

Closed
danielpastoor opened this issue Mar 8, 2023 · 5 comments
Closed

GetPagesAsync throwing an error #1131

danielpastoor opened this issue Mar 8, 2023 · 5 comments
Labels
area: pages API 📄 Working with modern pages question Further information is requested

Comments

@danielpastoor
Copy link
Contributor

Category

I get this error when i'm trying to get the home.aspx page.

System.Text.Json.JsonException: The JSON value could not be converted to System.Int32. Path: $.position.sectionIndex | LineNumber: 0 | BytePositionInLine: 107.
---> System.FormatException: Either the JSON value is not in a supported format, or is out of bounds for an Int32.
at System.Text.Json.ThrowHelper.ThrowFormatException(NumericType numericType)
at System.Text.Json.Serialization.Converters.Int32Converter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
at System.Text.Json.Serialization.Metadata.JsonPropertyInfo1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader) at System.Text.Json.Serialization.Converters.ObjectDefaultConverter1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.Metadata.JsonPropertyInfo1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) --- End of inner exception stack trace --- at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex) at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable1 actualByteCount)
at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo jsonTypeInfo)
at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
at PnP.Core.Model.SharePoint.CanvasControl.GetType(String controlDataJson)
at PnP.Core.Model.SharePoint.Page.LoadFromHtml(String html, String pageHeaderHtml)
at PnP.Core.Model.SharePoint.Page.LoadPageAsync(IList pagesLibrary, IListItem item)
at PnP.Core.Model.SharePoint.Page.LoadPagesAsync(PnPContext context, String pageName)
at PnP.Core.Model.SharePoint.Web.GetPagesAsync(String pageName)

Steps to reproduce

await pnpContext.Web.GetPagesAsync("home.aspx");

Expected behavior

To return the page data

Environment details (development & target environment)

  • SDK version: 1.8
  • OS: Windows 10
  • SDK used in: Console App
  • Framework: .NET core 7
@jansenbe
Copy link
Contributor

jansenbe commented Mar 9, 2023

@danielpastoor : can you debug this on your end or share the canvascontent1 field content from the home.aspx page list item? There's some JSON on that page that's not conform to what the pages API requires

@jansenbe jansenbe added question Further information is requested area: pages API 📄 Working with modern pages labels Mar 9, 2023
@danielpastoor
Copy link
Contributor Author

This is the breaking json:
{"controlType":4,"id":"00000000-0000-0000-0000-000000100000","position":{"zoneIndex":1.0,"sectionIndex":1.0,"controlIndex":1.0,"sectionFactor":12,"layoutIndex":1},"emphasis":{}}
Here an example of json that works:

{"controlType":3,"id":"00000000-0000-0000-0000-000000000001","position":{"zoneIndex":1,"sectionIndex":1,"controlIndex":1,"sectionFactor":12,"layoutIndex":1},"webPartId":"c4bd7b2f-7b6e-4599-8485-16504575f590","emphasis":{},"addedFromPersistedData":true}
{"controlType":3,"id":"00000000-0000-0000-0000-000000000002","position":{"zoneIndex":2,"sectionIndex":1,"controlIndex":1,"sectionFactor":8,"layoutIndex":1},"webPartId":"f92bf067-bc19-489e-a556-7fe95f508720","emphasis":{},"addedFromPersistedData":true}
{"controlType":3,"id":"00000000-0000-0000-0000-000000000003","position":{"zoneIndex":2,"sectionIndex":2,"controlIndex":1,"sectionFactor":4,"layoutIndex":1},"webPartId":"eb95c819-ab8f-4689-bd03-0c2d65d47b1f","emphasis":{},"addedFromPersistedData":true}
{"controlType":3,"id":"00000000-0000-0000-0000-000000000004","position":{"zoneIndex":3,"sectionIndex":1,"controlIndex":1,"sectionFactor":12,"layoutIndex":1},"webPartId":"8c88f208-6c77-4bdb-86a0-0c47b4316588","emphasis":{},"addedFromPersistedData":true,"reservedHeight":359,"reservedWidth":1156}
{"controlType":3,"id":"d622af52-fb3c-4349-baa4-73b6d2ca0000","position":{"zoneIndex":1,"sectionIndex":1,"controlIndex":1,"sectionFactor":12,"layoutIndex":2},"webPartId":"62cac389-787f-495d-beca-e11786162ef4","emphasis":{"zoneEmphasis":3},"addedFromPersistedData":true,"reservedHeight":370,"reservedWidth":348}
{"controlType":3,"id":"00000000-0000-0000-0000-000000000005","position":{"zoneIndex":1,"sectionIndex":1,"controlIndex":2,"sectionFactor":12,"layoutIndex":2},"webPartId":"20745d7d-8581-4a6c-bf26-68279bc123fc","emphasis":{"zoneEmphasis":3},"addedFromPersistedData":true,"reservedHeight":153,"reservedWidth":348}
{"controlType":3,"id":"00000000-0000-0000-0000-000000000006","position":{"zoneIndex":1,"sectionIndex":1,"controlIndex":3,"sectionFactor":12,"layoutIndex":2},"webPartId":"c70391ea-0b10-4ee9-b2b4-006d3fcad0cd","emphasis":{"zoneEmphasis":3},"addedFromPersistedData":true,"reservedHeight":358,"reservedWidth":348}
{"controlType":3,"id":"a875f1ed-f871-4682-89be-cdc9330e73e3","position":{"zoneIndex":1,"sectionIndex":1,"controlIndex":4,"sectionFactor":12,"layoutIndex":2},"webPartId":"7f718435-ee4d-431c-bdbf-9c4ff326f46e","emphasis":{"zoneEmphasis":3},"addedFromPersistedData":true,"reservedHeight":295,"reservedWidth":348}
{"controlType":0,"pageSettingsSlice":{"isDefaultDescription":true,"isDefaultThumbnail":true,"isSpellCheckEnabled":true,"globalRichTextStylingVersion":0,"rtePageSettings":{"contentVersion":4}}}

@danielpastoor
Copy link
Contributor Author

danielpastoor commented Mar 10, 2023

If i compare the master branch and the dev branch then I have found it is already fixed.
https://github.com/pnp/pnpcore/blob/master/src/sdk/PnP.Core/Model/SharePoint/Pages/Internal/CanvasPosition.cs
https://github.com/pnp/pnpcore/blob/dev/src/sdk/PnP.Core/Model/SharePoint/Pages/Internal/CanvasPosition.cs

In the dev branch the int is changed to a float. And that seems to be the fix. (pull request -> #1058)

I will use the nighly then for now.

@jansenbe for when is the new release sceduled?

@jansenbe
Copy link
Contributor

@danielpastoor : we're aiming for the end of March.

@danielpastoor
Copy link
Contributor Author

Thank you. I will close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: pages API 📄 Working with modern pages question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants