mercredi 4 février 2015

External websites calling Sharepoint data



I'm trying to figure out if what I'm looking to do is possible. We have existing websites that are not Sharepoint based. Internally, we have an anonymous enabled Sharepoint site we'd like to publish documents to and then from the external websites, use CSOM to call into it to pull the documents back and then display them on each website. I'm using the cross domain calls as described by MSDN:



var hostweburl;
var appweburl;

// Load the required SharePoint libraries
$(document).ready(function () {
//Get the URI decoded URLs.
hostweburl =
decodeURIComponent(
"http://ift.tt/1EGjYpu"
);
appweburl =
decodeURIComponent(
"http://ift.tt/1EGjYpu"
);

// resources are in URLs in the form:
// web_url/_layouts/15/resource
var scriptbase = hostweburl + "/_layouts/15/";

// Load the js files and continue to the successHandler
$.getScript(scriptbase + "SP.RequestExecutor.js", execCrossDomainRequest);
});

// Function to prepare and issue the request to get
// SharePoint data
function execCrossDomainRequest() {
// executor: The RequestExecutor object
// Initialize the RequestExecutor with the app web URL.
var executor = new SP.RequestExecutor(appweburl);

// Issue the call against the app web.
// To get the title using REST we can hit the endpoint:
// appweburl/_api/web/lists/getbytitle('listname')/items
// The response formats the data in the JSON format.
// The functions successHandler and errorHandler attend the
// sucess and error events respectively.
executor.executeAsync(
{
url:
appweburl +
"/_api/web/lists/getbytitle('Documents')/items",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: successHandler,
error: errorHandler
}
);
}


If I pull up the site in an external browser, I can navigate to it anonymously. But when I try to call it from other websites, I get the error message:



Could not complete cross-domain call: App Web is not deployed for this app's request url http://ift.tt/1EGjYpu


This is not a Sharepoint hosted application. It just a plain, external website trying to anonymously call into an anonymous enabled web application for its documents. Has anyone been able to accomplish this?








0 commentaires:

Enregistrer un commentaire