0

I use sharepoint online, I have a problem whe I load my page. I want to show a list with Rest/Api but I have this message : TypeError: SP.RequestExecutor is not a constructor

I think scripts is not loaded, how I can do ?

2
  • Can you please post the code that you are using?
    – grisha
    Sep 1, 2016 at 12:14
  • Why don't You mark achehab's answer as answer)
    – Gennady G
    Jan 26, 2017 at 15:25

2 Answers 2

1

You can find how to load and use SP.RequestExecutor on this link (which i will not mention here).

Another way to load it though is the following:

Make sure your app has "sp.js" registered as such:

<asp:Content ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
    <SharePoint:ScriptLink Name="sp.js" runat="server" OnDemand="true" LoadAfterUI="true" Localizable="false" />
    <!-- other scripts / styles here -->
</asp:Content>

To load the SP.RequestExecutor:

ExecuteOrDelayUntilScriptLoaded(function () {
    var scriptbase = _spPageContextInfo.siteAbsoluteUrl + "/_layouts/15/";

    // Load the js files and continue to the successHandler
    $.getScript(scriptbase + "SP.RequestExecutor.js", function () {
        console.log("request executor is now loaded");
        // Logic here
    });
}, "sp.js");
1

Add reference to your aspx or html page

<script type="text/javascript" src="/_layouts/15/SP.RequestExecutor.js"></script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.