SOLVED

PnP Get-PnPProvisioningTemplate subsite - 403 error

%3CLINGO-SUB%20id%3D%22lingo-sub-162076%22%20slang%3D%22en-US%22%3EPnP%20Get-PnPProvisioningTemplate%20subsite%20-%20403%20error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-162076%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI'm%20trying%20to%20extract%20a%20template%20from%20a%20subsite%20in%20my%20site%20collection.%3C%2FP%3E%0A%3CP%3EBut%20I%20get%20an%20(403)%20Forbidden%20error.%3C%2FP%3E%0A%3CP%3EWith%20tracelog%20on%20I%20see%20it%20is%20at%20Lists%20level%3A%3C%2FP%3E%0A%3CPRE%3Epowershell_ise.exe%20Information%3A%200%20%3A%202018-02-21%2010%3A05%3A51.0368%20%5BExtraction%5D%20%5B13%5D%20%5BDebug%5D%20Code%20execution%20scope%20started%200ms%20bf94329c-d433-47fd-88cf-825b011b6939%0Apowershell_ise.exe%20Information%3A%200%20%3A%202018-02-21%2010%3A05%3A51.0368%20%5BExtraction%5D%20%5B13%5D%20%5BDebug%5D%20Base%20template%20available%3A%20STS0template%200ms%20bf94329c-d433-47fd-88cf-825b011b6939%0Apowershell_ise.exe%20Information%3A%200%20%3A%202018-02-21%2010%3A05%3A51.0368%20%5BExtraction%5D%20%5B13%5D%20%5BDebug%5D%20ProgressDelegate%20registered%200ms%20bf94329c-d433-47fd-88cf-825b011b6939%0Apowershell_ise.exe%20Information%3A%200%20%3A%202018-02-21%2010%3A05%3A51.0368%20%5BExtraction%5D%20%5B13%5D%20%5BDebug%5D%20MessagesDelegate%20registered%201ms%20bf94329c-d433-47fd-88cf-825b011b6939%0Apowershell_ise.exe%20Information%3A%200%20%3A%202018-02-21%2010%3A05%3A51.3040%20%5BList%20instances%5D%20%5B13%5D%20%5BDebug%5D%20Code%20execution%20scope%20started%200ms%20bf94329c-d433-47fd-88cf-825b011b6939%0Apowershell_ise.exe%20Error%3A%200%20%3A%202018-02-21%2010%3A05%3A53.2420%20%5BOfficeDevPnP.Core%5D%20%5B0%5D%20%5BError%5D%20ExecuteQuery%20threw%20following%20exception%3A%20System.Net.WebException%3A%20The%20remote%20server%20returned%0A%20an%20error%3A%20(403)%20Forbidden.%0A%20%20%20at%20System.Net.HttpWebRequest.GetResponse()%0A%20%20%20at%20Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute()%0A%20%20%20at%20Microsoft.SharePoint.Client.ClientContext.GetFormDigestInfoPrivate()%0A%20%20%20at%20Microsoft.SharePoint.Client.ClientContext.EnsureFormDigest()%0A%20%20%20at%20Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()%0A%20%20%20at%20Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryImplementation(ClientRuntimeContext%20clientContext%2C%20Int32%20retryCount%2C%20Int32%20delay%2C%20String%20userAgent).%200ms%20%0Apowershell_ise.exe%20Information%3A%200%20%3A%202018-02-21%2010%3A05%3A53.2540%20%5BList%20instances%5D%20%5B13%5D%20%5BDebug%5D%20Code%20execution%20scope%20ended%201976ms%20bf94329c-d433-47fd-88cf-825b011b6939%0Apowershell_ise.exe%20Information%3A%200%20%3A%202018-02-21%2010%3A05%3A53.2550%20%5BExtraction%5D%20%5B13%5D%20%5BDebug%5D%20Code%20execution%20scope%20ended%202245ms%20bf94329c-d433-47fd-88cf-825b011b6939%3C%2FPRE%3E%0A%3CP%3EAny%20ideas%20why%20I%20get%20the%20403%3F%3C%2FP%3E%0A%3CP%3EI've%20tried%20with%20newly%20created%20clean%20subsite%20and%20have%20the%20same%20error.%3C%2FP%3E%0A%3CP%3EIf%20I%20try%20to%20get%20the%20template%20of%20the%20Site%20Collection%20itself%20it%20works.%20Only%20subsites%20give%20the%20error.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks%2C%3C%2FP%3E%0A%3CP%3EPeter%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-162088%22%20slang%3D%22en-US%22%3ERe%3A%20PnP%20Get-PnPProvisioningTemplate%20subsite%20-%20403%20error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-162088%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20using%26nbsp%3B%26nbsp%3B-UseWebLogin%20to%20connect%20(due%20to%20local%20environment).%3C%2FP%3E%0A%3CP%3EApparently%20this%20gives%20errors%20for%20subsites.%3C%2FP%3E%0A%3CP%3EWith%20another%20authentication%20method%20it%20seems%20to%20work.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hi,

 

I'm trying to extract a template from a subsite in my site collection.

But I get an (403) Forbidden error.

With tracelog on I see it is at Lists level:

powershell_ise.exe Information: 0 : 2018-02-21 10:05:51.0368	[Extraction]	[13]	[Debug]	Code execution scope started	0ms	bf94329c-d433-47fd-88cf-825b011b6939
powershell_ise.exe Information: 0 : 2018-02-21 10:05:51.0368	[Extraction]	[13]	[Debug]	Base template available: STS0template	0ms	bf94329c-d433-47fd-88cf-825b011b6939
powershell_ise.exe Information: 0 : 2018-02-21 10:05:51.0368	[Extraction]	[13]	[Debug]	ProgressDelegate registered	0ms	bf94329c-d433-47fd-88cf-825b011b6939
powershell_ise.exe Information: 0 : 2018-02-21 10:05:51.0368	[Extraction]	[13]	[Debug]	MessagesDelegate registered	1ms	bf94329c-d433-47fd-88cf-825b011b6939
powershell_ise.exe Information: 0 : 2018-02-21 10:05:51.3040	[List instances]	[13]	[Debug]	Code execution scope started	0ms	bf94329c-d433-47fd-88cf-825b011b6939
powershell_ise.exe Error: 0 : 2018-02-21 10:05:53.2420	[OfficeDevPnP.Core]	[0]	[Error]	ExecuteQuery threw following exception: System.Net.WebException: The remote server returned
 an error: (403) Forbidden.
   at System.Net.HttpWebRequest.GetResponse()
   at Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute()
   at Microsoft.SharePoint.Client.ClientContext.GetFormDigestInfoPrivate()
   at Microsoft.SharePoint.Client.ClientContext.EnsureFormDigest()
   at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
   at Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryImplementation(ClientRuntimeContext clientContext, Int32 retryCount, Int32 delay, String userAgent).	0ms	
powershell_ise.exe Information: 0 : 2018-02-21 10:05:53.2540	[List instances]	[13]	[Debug]	Code execution scope ended	1976ms	bf94329c-d433-47fd-88cf-825b011b6939
powershell_ise.exe Information: 0 : 2018-02-21 10:05:53.2550	[Extraction]	[13]	[Debug]	Code execution scope ended	2245ms	bf94329c-d433-47fd-88cf-825b011b6939

Any ideas why I get the 403?

I've tried with newly created clean subsite and have the same error.

If I try to get the template of the Site Collection itself it works. Only subsites give the error.

 

Thanks,

Peter

1 Reply
Best Response confirmed by Peter ... (New Contributor)
Solution

I'm using  -UseWebLogin to connect (due to local environment).

Apparently this gives errors for subsites.

With another authentication method it seems to work.