2

I'm creating an SharePoint app (add-in?). Now I'd like to get data from a list in my host web using CSOM/JavaScript:

var context = new SP.ClientContext(appWebUrl);
var factory = new SP.ProxyWebRequestExecutorFactory(appWebUrl);
context.set_webRequestExecutorFactory(factory);
var appContextSite = new SP.AppContextSite(context, hostUrl);

Problem is my SP object doesn't support the method ProxyWebRequestExecutorFactory (or so the debugger says)? SP.js is loaded and my client context object is initialized. Any ideas what is wrong?

My environment: SharePoint 2013 on-premise

1
  • Without directly answering your question, I've found that you can skip setting the webRequestExecutorFactory at all and things still generally work... despite the examples provided on MSDN explicitly using the syntax you highlight. May be worth a shot Commented Sep 8, 2015 at 11:52

2 Answers 2

2

dstarkowski got me on track, sp.requestexecutor.js had not been initialized properly. This worked out for me:

$(function () {
  $.getScript(scriptbase + "SP.RequestExecutor.js", execCrossDomainRequest);
});

function execCrossDomainRequest() { 
  var context = new SP.ClientContext(appWebUrl);
  var factory = new SP.ProxyWebRequestExecutorFactory(appWebUrl);
  [...]
}
0
1

According to this article, SP.ProxyWebRequestExecutorFactory is located in sp.requestexecutor.js file. Is it included in your application?

1
  • Thanks for reply. Yes, I have a reference to sp.requestexecutor.js. Commented Sep 8, 2015 at 8:16

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.