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

%3CLINGO-SUB%20id%3D%22lingo-sub-26726%22%20slang%3D%22en-US%22%3EIntermittent%20%22403%20-%20Forbidden%22%20error%20while%20running%20web.ApplyProvisioningTemplate%20on%20SPO%20sites.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-26726%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3CBR%20%2F%3E%3CBR%20%2F%3EMy%20customer%20is%20using%20a%20PnP%20framework-based%20custom%20SPO%20site%20provisioning%20tool.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20applying%20an%20XML%20template%20to%20an%20SPO%20site%2C%20the%20PnP%20function%20web.ApplyProvisioningTemplate(ProvisioningTemplate%2C%20ProvisioningTemplateApplyingInformation)%20sometimes%20(in%20about%2020%25%20of%20cases)%20throws%20the%20following%20error%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20The%20remote%20server%20returned%20an%20error%3A%20(403)%20Forbidden%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3EThe%20frequency%20of%20the%20error%20does%20not%20depend%20on%20a%20specific%20XML%20template%20and%20is%20not%20consistently%20tied%20to%20a%20specific%20step%20in%20the%20template%20application%20process%20(although%20%22List%20instances%22%20step%20seems%20to%20trigger%20the%20error%20more%20frequently%20than%20others).%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3EThe%20tool%20is%20using%20the%201.7.1015.1%20Version%20of%20PnP%20framework.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3EDoes%20this%20scenario%20look%20familiar%20to%20anyone%3F%20Has%20anyone%20been%20able%20to%20identify%20the%20cause%3F%20Has%20this%20issue%2C%20by%20any%20chance%2C%20been%20addressed%20in%20one%20of%20the%20later%20versions%20of%20PnP%20framework%3F%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3EThank%20you%20very%20much!%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3EDmitry%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-26726%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-30126%22%20slang%3D%22en-US%22%3ERe%3A%20Intermittent%20%22403%20-%20Forbidden%22%20error%20while%20running%20web.ApplyProvisioningTemplate%20on%20SP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-30126%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20not%20using%20it%20often%2C%20I%20accepted%20that%20it%20works%20this%20way%20and%20I%20can%20live%20with%20it%2C%20so%20I%20have%20not%20ever%20measured%2C%20but%20as%20far%20as%20I%20remember%2C%20it%20was%20about%2010%20mins%20or%20so.%20My%20feeling%20is%20that%20it's%20somewhat%20random%2C%20at%20least%20I%20remember%20cases%20where%20it%20worked%20fine%2C%20while%20in%20other%20cases%20it%20ran%20into%20error%20403.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-29616%22%20slang%3D%22en-US%22%3ERe%3A%20Intermittent%20%22403%20-%20Forbidden%22%20error%20while%20running%20web.ApplyProvisioningTemplate%20on%20SP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-29616%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20Zoltan!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDo%20you%20have%20an%20estimate%20of%20how%20long%20the%20wait%20should%20be%3F%20We%20are%20using%20the%20PnP%20code%20in%26nbsp%3Ban%20automated%20solution%2C%20so%20trying%20to%20come%20up%20with%20a%20more%20precise%20algorithm...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAlso%2C%20were%20you%20able%20to%20determine%20any%20pattern%20to%20this%20issue%20through%20your%20observations%2C%20or%20does%20it%20appear%20to%20be%20completely%20random%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-27630%22%20slang%3D%22en-US%22%3ERE%3A%20Intermittent%20%22403%20-%20Forbidden%22%20error%20while%20running%20web.ApplyProvisioningTemplate%20on%20SPO%20sites.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-27630%22%20slang%3D%22en-US%22%3Eplease%20check%20your%20version.%20If%20that%20is%20all%20the%20latest%20first%20comment%20your%20template%20and%20recover%20peace%20by%20peace%20till%20you%20find%20the%20issue.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-27235%22%20slang%3D%22en-US%22%3ERe%3A%20Intermittent%20%22403%20-%20Forbidden%22%20error%20while%20running%20web.ApplyProvisioningTemplate%20on%20SP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-27235%22%20slang%3D%22en-US%22%3E%3CP%3EAbsolutely%20familiar%2C%20in%20a%20scenario%20where%20I%20create%20a%20site%20with%26nbsp%3BNew-SPOTenantSite%20and%20then%20apply%20a%20.pnp%20(so%20not%20an%20.xml%2C%20but%20I%20don't%20think%20it%20matters)%20template%20in%20the%20same%20script.%20When%20I%20run%20into%20this%20problem%2C%20the%20same%20happens%20with%20other%20PnP%20commands%20I%20use%20on%20the%20new%20site%20in%20my%20script%2C%20even%20though%20I'm%20able%20to%20connect%20to%20that%20new%20site%20with%26nbsp%3BConnect-SPOnline%2C%20and%20the%20new%26nbsp%3Bsite%20is%20accessible%20through%20a%20browser%20with%20the%20same%20user%20for%20which%20I%20got%20the%20%22403%3A%20Forbidden%22%20error%20for%20the%20PnP%20commands.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20solution%20(more%20precisely%2C%20the%20workaround)%20is%20to%20wait%20for%20a%20while%2C%20and%20then%20try%20to%20run%20again%20these%20previously%20failed%20PnP%20commands%26nbsp%3B%20-%20after%20a%20waiting%20period%20they%20work%20properly.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-27179%22%20slang%3D%22en-US%22%3ERe%3A%20Intermittent%20%22403%20-%20Forbidden%22%20error%20while%20running%20web.ApplyProvisioningTemplate%20on%20SP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-27179%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMaybe%20an%20authentication%20issue.%20Try%20to%20use%20Fiddler%20to%20capture%20failing%20requests%20and%20check%20if%20they%20have%20auth%20cookies.%20Try%20to%20reissue%20those%20requests%20that%20succeeded%20before%20and%20see%20if%20it%20works.%3C%2FP%3E%3CP%3E__%3C%2FP%3E%3CP%3EBr%2C%20Ivan%3C%2FP%3E%3C%2FLINGO-BODY%3E
New 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.