Im trying to make this call in a app for accessing data from a list on the hosturl. but it not working, whats wrong in it?
function execCrossDomainRequest() {
var executor = new SP.RequestExecutor(appweburl);
for (var i = 0; i < newsList.length; i++) {
var soapEnv = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>";
soapEnv += " <soapenv:Body>";
soapEnv += " <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>";
soapEnv += " <listName>" + newsList[i].ListName + "</listName>";
soapEnv += " <query>";
soapEnv += " <Query>";
soapEnv += " <OrderBy Override='TRUE'>";
soapEnv += " <FieldRef Name='Created' Ascending='FALSE' />";
soapEnv += " </OrderBy>";
var currentDate = new Date();
currentDate = currentDate.toISOString();
soapEnv += " <Where>";
soapEnv += " <And>";
soapEnv += " <Or>";
soapEnv += " <IsNull>";
soapEnv += " <FieldRef Name='PublicTo' />";
soapEnv += " </IsNull>";
soapEnv += " <Leq>";
soapEnv += " <FieldRef Name='PublicFrom' />";
soapEnv += " <Value Type='DateTime' IncludeTimeValue='True'>" + currentDate + "</Value>";
soapEnv += " </Leq>";
soapEnv += " </Or>";
soapEnv += " <Or>";
soapEnv += " <IsNull>";
soapEnv += " <FieldRef Name='PublicTo' />";
soapEnv += " </IsNull>";
soapEnv += " <Geq>";
soapEnv += " <FieldRef Name='PublicFrom' />";
soapEnv += " <Value Type='DateTime' IncludeTimeValue='True'>" + currentDate + "</Value>";
soapEnv += " </Geq>";
soapEnv += " </Or>";
soapEnv += " </And>";
soapEnv += " </Where>";
soapEnv += " </Query>";
soapEnv += " </query>";
soapEnv += " <queryOptions>";
soapEnv += " <QueryOptions>";
soapEnv += " <IncludeMandatoryColumns>TRUE</IncludeMandatoryColumns>";
soapEnv += " </QueryOptions>";
soapEnv += " </queryOptions>";
soapEnv += " <viewFields>";
soapEnv += " <ViewFields>";
soapEnv += " <FieldRef Name='ows_Title'/>";
soapEnv += " <FieldRef Name='ows_Body'/>";
soapEnv += " <FieldRef Name='show'/>";
soapEnv += " <FieldRef Name='pic'/>";
soapEnv += " <FieldRef Name='ows_FileLeafRef'/>";
soapEnv += " </ViewFields>";
soapEnv += " </viewFields>";
var rowLimit = MaxAllNews;
soapEnv += " <rowLimit>" + rowLimit + "</rowLimit>";
soapEnv += " </GetListItems>";
soapEnv += " </soapenv:Body>";
soapEnv += "</soapenv:Envelope>";
var port = window.location.port;
if (port.length <= 0)
port = "";
else
port = ":" + port;
var webservice = hostUrl + "/_vti_bin/lists.asmx";
var imageURL = hostUrl + "/pics/";
executor.executeAsync({
url: webservice,
method: "POST",
dataType: "xml",
data: soapEnv,
async: false,
contentType: "text/xml; charset=\"utf-8\"",
complete: function (xData, status) {
console.log('Success!');
},
error: function (xhr) {
console.log('Error! Status = ' + xhr.status);
}
});
}
}