Wednesday, March 16, 2016

Uncaught TypeError: SP.ProxyWebRequestExecutorFactory is not a function

Environment: Office 365, SharePoint Online, Visual Studio 2015, SharePoint JSOM


Scenario: Create a SharePoint hosted app to get the SharePoint list details from the root web.

Error: Uncaught TypeError: SP.ProxyWebRequestExecutorFactory is not a function


Code snippet where the error has occurred is marked in red


   hostwebUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
   appwebUrl = decodeURIComponent(getQueryStringParameter("SPAppWebUrl"));
   context = new SP.ClientContext(appwebUrl);
   factory = new SP.ProxyWebRequestExecutorFactory(appwebUrl);


Troubleshooting: According to this article, SP.ProxyWebRequestExecutorFactory is member of Request Executor(sp.requestexecutor.js). So the script file should be loaded explicitly in order to avoid the error.


Fix: Reference the SP.RequestExecutor.js in the page
<script type="text/javascript" src="/_layouts/15/SP.RequestExecutor.js"></script>






No comments:

Post a Comment