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

  • 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 – John-M Sep 8 '15 at 11:52
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);
  [...]
}
1

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

  • Thanks for reply. Yes, I have a reference to sp.requestexecutor.js. – kolback Sep 8 '15 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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