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

LoadListDataAsStreamAsync: System.InvalidOperationException: The requested operation requires an element of type 'Object', but the target element has type 'String'. #1588

Open
1 task done
2Who opened this issue Dec 4, 2024 · 1 comment
Labels
area: model 📐 Related to the core SDK models question Further information is requested

Comments

@2Who
Copy link

2Who commented Dec 4, 2024

Category

  • Bug

Describe the bug

We have a SharePoint Online document library and for some documents the function "LoadListDataAsStream" runs into an error.
The problem seems to be related to the the metadata fields of the documents.
Unlike issue #1365 we don't use any image field data or location field data.

We call the function like this:

List.LoadListDataAsStream(new RenderListDataOptions()
{
    ViewXml = ViewXml,
    RenderOptions = RenderListDataOptionsFlags.ListData
});

The ViewXML looks like this:

<View>
	<Query>
		<Where>
			<In>
				<FieldRef Name='ID'/>
				<Values>
					<Value Type='Number'>40</Value>
				</Values>
			</In>
		</Where>
	</Query>
</View>

The error message is System.InvalidOperationException:

'The requested operation requires an element of type 'Object', but the target element has type 'String'.'

And the stacktrace of the error is:

at System.Text.Json.ThrowHelper.ThrowJsonElementWrongTypeException(JsonTokenType expectedType, JsonTokenType actualType)
at System.Text.Json.JsonElement.EnumerateObject()
at PnP.Core.Model.SharePoint.ListDataAsStreamHandler.TransformRowData(JsonElement row, IFieldCollection fields, Dictionary`2 fieldLookupCache)
at PnP.Core.Model.SharePoint.ListDataAsStreamHandler.d__1.MoveNext()
at PnP.Core.Model.SharePoint.List.d__198.MoveNext()
at PnP.Core.Model.SharePoint.List.LoadListDataAsStream(RenderListDataOptions renderOptions)

Steps to reproduce

Since the error is specific to documents within our company and without knowing what the underlying problem is, I can't provide steps to reproduce.

Expected behavior

Loading the list items without an error.

Environment details (development & target environment)

  • SDK version: [1.14.0]
  • OS: [Windows 10]
  • SDK used in: [Console App]
  • Framework: [.NET 8.0 ]
  • Tooling: [Visual Studio 2022]
  • SharePoint environment: [SharePoint Online]

Additional context

We are migrating documents from SharePoint 2019 to SharePoint Online.

@jansenbe
Copy link
Contributor

@2Who : do you have an option to capture a Fiddler trace when reproducing, that will show the payload we get back from SharePoint. The code that processes the metadata payload seems to be failing, without understanding those details it will be really hard to repro/fix.

@jansenbe jansenbe added question Further information is requested area: model 📐 Related to the core SDK models labels Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: model 📐 Related to the core SDK models question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants