You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm newish to using PnP so not sure how to handle this scenario. I've tried a few different things and I'm stuck.
I'm trying to load items from a large list using LoadListDataAsStreamBatchAsync. I have two requests in my batch that request all items from the list, each batch having a different set of fields. Then I do ExecuteAsync on the batch, later iterating over list.Items.AsRequested with a foreach. Something like this:
try
{
RenderListDataOptions renderOptions = new RenderListDataOptions()
{
ViewXml = viewXml,
RenderOptions = RenderListDataOptionsFlags.ListData,
DatesInUtc = true
};
await list.LoadListDataAsStreamBatchAsync(batch, renderOptions).ConfigureAwait(false);
await pnpContext.ExecuteAsync(batch, false).ConfigureAwait(false);
foreach (IListItem item in list.Items.AsRequested())
{
// do stuff with the item
}
}
catch(Exception e)
{
// log
}
I run it on one list and it's perfect - I get all items back. On a second list, I get a JSON deserialization error that stops all processing. I've found that there is a person column that must have been switched from multi to single and the column ended up with some arrays where there should be strings.
I need to go into the list and correct the corrupt data, but how can I catch deserialization exceptions like that in the future? I thought this setup, or something similar, would allow me to process the items one-by-one but that only seems to be the case once deserializing happens. I need to trap the exception during deserialization. And my catch block doesn't catch the exception at all - the exception throws on ExecuteAsync, but it gets swallowed up somewhere in PnP. I only see something about it in the Output window, or I get an Unhandled Exception when I debug.
Am I doing it wrong, or is this item-by-item exception catching not doable?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi All,
I'm newish to using PnP so not sure how to handle this scenario. I've tried a few different things and I'm stuck.
I'm trying to load items from a large list using LoadListDataAsStreamBatchAsync. I have two requests in my batch that request all items from the list, each batch having a different set of fields. Then I do ExecuteAsync on the batch, later iterating over list.Items.AsRequested with a foreach. Something like this:
I run it on one list and it's perfect - I get all items back. On a second list, I get a JSON deserialization error that stops all processing. I've found that there is a person column that must have been switched from multi to single and the column ended up with some arrays where there should be strings.
I need to go into the list and correct the corrupt data, but how can I catch deserialization exceptions like that in the future? I thought this setup, or something similar, would allow me to process the items one-by-one but that only seems to be the case once deserializing happens. I need to trap the exception during deserialization. And my catch block doesn't catch the exception at all - the exception throws on ExecuteAsync, but it gets swallowed up somewhere in PnP. I only see something about it in the Output window, or I get an Unhandled Exception when I debug.
Am I doing it wrong, or is this item-by-item exception catching not doable?
Thanks for any guidance.
Beta Was this translation helpful? Give feedback.
All reactions