Replies: 1 comment 1 reply
-
|
That is some good question and feedback. pnpcore/src/sdk/PnP.Core/Model/SharePoint/Core/Internal/ListItem.cs Lines 190 to 217 in 07bd476 We just read the HasException and handle the error but we do not parse and pass one the error code and error message.What we could do is:
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I'm running into a situation where PnP.Core hides the actual SharePoint error when inserting an item into a list that has a unique-value constraint on a column.
PnP.Core
In PnP.Core using list.Items.AddAsync(fields), a duplicate violation throws:
SharePointRestServiceException: There was an exception while writing field [FieldName]. Verify you're using the correct InternalName value for the field you want to write to.Error-Property of Exception is null. Message is too generic, there is no way to distinguish a duplicate value error from a wrong field name.
CSOM
In CSOM using Microsoft.SharePoint.Client.ClientContext with ExecuteQueryAsync, a duplicate violation throws a ServerException with full details directly on the exception:
ServerErrorCode = -2130575169 HResult = -2146233088 ServerErrorTypeName = "Microsoft.SharePoint.SPDuplicateValuesFoundException" Message = "The list item could not be added or updated because duplicate values were found in the following field(s) in the list: [FieldName]"Is there a supported way with PnP.Core to get the ErrorCode / ErrorMessage out of SharePointRestServiceException without falling back to CSOM?
Beta Was this translation helpful? Give feedback.
All reactions