Intermittent "403 - Forbidden" error while running web.ApplyProvisioningTemplate on SPO sites.

Copper Contributor

Hello,

My customer is using a PnP framework-based custom SPO site provisioning tool. 

 

When applying an XML template to an SPO site, the PnP function web.ApplyProvisioningTemplate(ProvisioningTemplate, ProvisioningTemplateApplyingInformation) sometimes (in about 20% of cases) throws the following error:

       The remote server returned an error: (403) Forbidden

The frequency of the error does not depend on a specific XML template and is not consistently tied to a specific step in the template application process (although "List instances" step seems to trigger the error more frequently than others).

The tool is using the 1.7.1015.1 Version of PnP framework.

Does this scenario look familiar to anyone? Has anyone been able to identify the cause? Has this issue, by any chance, been addressed in one of the later versions of PnP framework?

Thank you very much!

Dmitry

5 Replies

Hi,

 

Maybe an authentication issue. Try to use Fiddler to capture failing requests and check if they have auth cookies. Try to reissue those requests that succeeded before and see if it works.

__

Br, Ivan

Absolutely familiar, in a scenario where I create a site with New-SPOTenantSite and then apply a .pnp (so not an .xml, but I don't think it matters) template in the same script. When I run into this problem, the same happens with other PnP commands I use on the new site in my script, even though I'm able to connect to that new site with Connect-SPOnline, and the new site is accessible through a browser with the same user for which I got the "403: Forbidden" error for the PnP commands.

 

The solution (more precisely, the workaround) is to wait for a while, and then try to run again these previously failed PnP commands  - after a waiting period they work properly.

please check your version. If that is all the latest first comment your template and recover peace by peace till you find the issue.

Thanks Zoltan!

 

Do you have an estimate of how long the wait should be? We are using the PnP code in an automated solution, so trying to come up with a more precise algorithm...

 

Also, were you able to determine any pattern to this issue through your observations, or does it appear to be completely random?

I'm not using it often, I accepted that it works this way and I can live with it, so I have not ever measured, but as far as I remember, it was about 10 mins or so. My feeling is that it's somewhat random, at least I remember cases where it worked fine, while in other cases it ran into error 403.