Forum Discussion

Shaohui's avatar
Shaohui
Icon for Microsoft rankMicrosoft
Jan 20, 2022

Cannot delete team site via PnP framework 1.7

Hi all,

 

I am the engineer at the Seamless Teamwork Governance team under the Microsoft Digital department. We plan to use the API below to delete the site of Sharepoint for our project.

 

PnP.Framework v1.7: Microsoft.SharePoint.Client.ClientContextExtensions.DeleteSiteAsync(this ClientContext clientContext)

 

Currently, the communication site can be successfully deleted via the API. However, I see the following errors when deleting the team site. Both deletion calls use the exactly same code logic, and the only difference is the web url. Could anyone help us know why the API fails to delete the team site? Does it need any specific configuration? Or are there any API documents we can refer to?

Please let me know if you need more information for the questions. Thanks in advance!

 

 

 

Name

Value

Type

 

Data

System.Collections.ListDictionaryInternal

System.Collections.IDictionary {System.Collections.ListDictionaryInternal

 

Message

"{\"odata.error\":{\"code\":\"-1, System.Data.Services.Client.DataServiceRequestException\",\"message\":{\"lang\":\"en-US\",\"value\":\"An error occurred while processing this request.\"}}}"

string

 

team site sample:                  https://m365x385246.sharepoint.com/sites/jbegleytest

communication site sample: https://m365x385246.sharepoint.com/sites/ctest2

   at PnP.Framework.Utilities.RESTUtilities.<ExecutePostAsync>d__1.MoveNext() in /_/src/lib/PnP.Framework/Utilities/RESTUtilities.cs:line 121
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in /_/src/System.Private.CoreLib/shared/System/Runtime/ExceptionServices/ExceptionDispatchInfo.cs:line 63
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in /_/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs:line 180
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in /_/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs:line 151
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() in /_/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs:line 369
   at PnP.Framework.Sites.SiteCollection.<DeleteSiteAsync>d__28.MoveNext() in /_/src/lib/PnP.Framework/Sites/SiteCollection.cs:line 1467
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in /_/src/System.Private.CoreLib/shared/System/Runtime/ExceptionServices/ExceptionDispatchInfo.cs:line 63
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in /_/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs:line 180
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in /_/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs:line 151
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() in /_/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs:line 369
   at Microsoft.SharePoint.Client.ClientContextExtensions.<DeleteSiteAsync>d__34.MoveNext() in /_/src/lib/PnP.Framework/Extensions/ClientContextExtensions.cs:line 1110
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in /_/src/System.Private.CoreLib/shared/System/Runtime/ExceptionServices/ExceptionDispatchInfo.cs:line 63
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in /_/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs:line 180
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in /_/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs:line 151
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() in /_/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs:line 369
   at Eue.Governance.Sharepoint.SharePointContextAdapter.<Delete>d__27.MoveNext() in C:\Dev\Code\Microsoft\STW-GOV-ConGov-GroupLifecycleMgt\Governance.Sharepoint\Eue.Governance.Sharepoint\SharePointContextAdapter.cs:line 284
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in /_/src/System.Private.CoreLib/shared/System/Runtime/ExceptionServices/ExceptionDispatchInfo.cs:line 63
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in /_/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs:line 180
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in /_/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs:line 151
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() in /_/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs:line 369
   at Eue.Governance.Sharepoint.SharePointAdminClient.<DeleteSite>d__42.MoveNext() in C:\Dev\Code\Microsoft\STW-GOV-ConGov-GroupLifecycleMgt\Governance.Sharepoint\Eue.Governance.Sharepoint\SharePointAdminClient.cs:line 1457

 

 

No RepliesBe the first to reply

Resources