I am developing a Sharepoint App, and in the app, I need to display projects and resources. The application is hosted on an Office 365 PWA instance.
The app web url is a uniquely generated url and for the app in this domain to talk to the host web, it would be considered a cross domain call. I am using SP.RequestExecutor to make the cross domain call, but it gives me an error:
</m:error>
The query url that I am using in the SP.RequestExecutor looks like this:
https://myapp-uniqueidentifier.sharepoint.com/sites/pwa/MYProjectName/custom/_api/SP.AppContextSite(@target)/ProjectData/Projects?$select=ProjectName&@target='https://myapp.sharepoint.com/sites/pwa/MyProjectName'
Please note that using almost the same code, I can query SP List service on the host, and that works fine, just not the ProjectData service.
The code looks like this:
var deferred = this.$q.defer();var executor = new SP.RequestExecutor(this.spContext.hostWeb.appWebUrl);
executor.executeAsync({
url: this.spContext.hostWeb.appWebUrl + "/_api/ProjectData/Projects&@target='" + this.spContext.hostWeb.url + "'",
method: "GET",
headers: {
"Accept": "application/json; odata=verbose"
//,"X-RequestDigest": this.spContext.securityValidation
},
success: function (data) {
var jsonobject = JSON.parse(data.body);
deferred.resolve(jsonobject.d);
},
error: function (data, errorCode, errorMessage) {
deferred.reject(data);
self.common.logger.logError("Error retrieving projects", errorMessage, serviceId);
}
});