I am trying to get data from SharePoint and display it in an HTML page on a separate domain using SharePoint 2013's API. The SP instance sits on-prem and the other domain is also within our firewall (on a different server). Here are some of the resources I used to put this together: http://msdn.microsoft.com/en-us/library/office/jj164022(v=office.15).aspx
http://weshackett.com/2014/02/sp-requestexecutor-cross-domain-calls-using-rest-gotcha/
<script src="https://ideas.simplot.com/_layouts/15/SP.RequestExecutor.js"></script>
<script>
var executor;
var appWebUrl = "http://mysharepointdomain";
var hostWebUrl = "http://theotherdomain";
// Initialize the RequestExecutor with the app web URL.
executor = new SP.RequestExecutor(appWebUrl);
function successHandler(data) {
console.log(data);
}
function errorHandler(data) {
console.log(data);
}
//Get all the available task lists from the host web
function getData() {
executor.executeAsync({
//url:appWebUrl + "/_api/SP.AppContextSite(@target)/web/lists/?$filter=BaseTemplate eq 171&$select=ID,Title,ImageUrl,ItemCount,ListItemEntityTypeFullName&@target='" + hostWebUrl + "'",
url:appWebUrl + "/_api/SP.AppContextSite(@target)/web?@target='" + hostWebUrl + "'",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: successHandler,
error: errorHandler
});
}
getData();
</script>
This is what I get back from the call in the browsers; which is essentially nothing...
SP.ResponseInfo {responseAvailable: false, body: "", statusCode: undefined, statusText: undefined, contentType: undefined…}
allResponseHeaders: undefined
binaryStringResponseBody: undefined
body: ""
contentType: undefined
headers: null
responseAvailable: false
state: undefined
statusCode: undefined
statusText: undefined
And this is the XML I get if I enter the app web url into the browser.
Example URL: <mysharepointdomain>/_api/SP.AppContextSite%28@target%29/web?@target=%27theotherdomain%27
XML Returned in the browser:
<m:error>
<m:code>-1, Microsoft.SharePoint.SPException</m:code>
<m:message xml:lang="en-US">There is no app context to execute this request.</m:message>
</m:error>
If anyone has any insight on why this is not working, it would be much appreciated. The other domain site is not a Sharepoint app or page. It is a non Sharepoint application sitting on a Linux server. The site is not passing any user credentials to sp right now which may be part of the issue?