PnP provisioning fails on invalid response

Not applicable

We are working on an solution which is supported by multiple PnP templates and as we are building new functionality we are deploying sites using these templates to different tenants for test and acceptance purposes. Lately, last few weeks, we are increasing encountering CSOM request limit exceeded warnings but more importantly random errors on ProcessResponseStream. Looks like our tenant refuses to answers correctly... The issue is not related to a specific item in de template. It fails at random points. And when tried again after the error message all is working fine.

Anyone else having this issue? Are we doing something wrong or is this just how Office 365 reacts when receiving too many requests?

@PNP Team: ExecuteRetry method in PnP only catches the webexceptions. Maybe good to check whether retry option can also include errors occurring when processing the response.


Stack trace of one of the error:

Exception Microsoft.SharePoint.Client.ServerException: Ending value cannot be less than starting value.

at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)
at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb)
at Microsoft.SharePoint.Client.ClientRequest.ExecuteQuery()
at Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQuery()
at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
at Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryImplementation(ClientRuntimeContext clientContext, Int32 retryCount, Int32 delay)
at Microsoft.SharePoint.Client.FieldAndContentTypeExtensions.AddContentTypeToList(List list, ContentType contentType, Boolean defaultContent)
at Microsoft.SharePoint.Client.FieldAndContentTypeExtensions.AddContentTypeToListById(List list, String contentTypeID, Boolean defaultContent, Boolean searchContentTypeInSiteHierarchy)
at OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.ObjectListInstance.CreateList(Web web, ListInstance list, TokenParser parser, PnPMonitoredScope scope, Boolean isNoScriptSite)
at OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.ObjectListInstance.ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation)
at OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.SiteToTemplateConversion.ApplyRemoteTemplate(Web web, ProvisioningTemplate template, ProvisioningTemplateApplyingInformation provisioningInfo)
7 Replies



Have you looked at the tenant migration sample in PnP PowerShell. It does roughly what you are trying to do.


Which version of PnP PowerShell are you using.


My initial thought are that you need to include some connect-Pnponline commands before every Apply-PnPProvisioningTemplate. This should not be needed but it will cleanup things a bit.




Thx for the suggestion Pieter!


We have a custom c# provisioning application with PnP version 2.15.1705.0, via Nuget.


We are provisioning multiple templates for sitecollection and subsites. Would it help if new start a new context before each apply template action?

Hi @Deleted,


Yes, that would do the same. No guarantees that it would help but definitely worth a try.

Thx @Pieter Veenstra


I checked the logic of our provisioning application and it already creates a new context for the sitecollection and each sub site. 


Any other ideas or suggestions? 

Hi Suleyman,


did you already try with the dev branch? 

@Vesa Juvonen could there be a change . in throttling?

@Deleted: Not sure what to make of the links you submitted. I don't see any info that is related to our problem.


@Deleted: Haven't tried the dev branch. We will update to latest version of PnP next week. We do see that the templates we used months ago, without issues, are now failing regularly.