Quantcast
Channel: Project Customization and Programming forum
Viewing all articles
Browse latest Browse all 5347

Problem making cross-domain call to Project Online OData feed from Sharepoint App

$
0
0

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 xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<m:code>-2147024891, System.UnauthorizedAccessException</m:code>
<m:message xml:lang="en-US">
Access denied. You do not have permission to perform this action or access this resource.
</m:message>

</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);
                }
            });


Viewing all articles
Browse latest Browse all 5347

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>