I am trying to create a sharepoint hosted app. That app is hosted on a sharepoint online site.

It is supposed to access data from a sharepoint online list that is on another site collection (but in the same office365 domain).

Everything is working over http.

I found an example on msdn that gets data from odata.org. When I use this code it works very well :

    var context = SP.ClientContext.get_current();
    var request = new SP.WebRequestInfo();

    // We need the response formatted as JSON.
    request.set_headers({ "Accept": "application/json;odata=verbose" });
    var response = SP.WebProxy.invoke(context, request);

    // Let users know that there is some
    // processing going on.
    document.getElementById("categories").innerHTML =
                "<P>Loading categories...</P>";

    // Set the event handlers and invoke the request.
    context.executeQueryAsync(successHandler, errorHandler);

    function successHandler() {
        // Check for status code == 200
        // Some other status codes, such as 302 redirect
        // do not trigger the errorHandler. 
        if (response.get_statusCode() == 200) {
            var categories;
            var output;

            // Load the OData source from the response.
            categories = JSON.parse(response.get_body());

            // Extract the CategoryName and Description
            // from each result in the response.
            // Build the output as a list.
            output = "<UL>";
            for (var i = 0; i < categories.d.results.length; i++) {
                var categoryName;
                var description;
                categoryName = categories.d.results[i].CategoryName;
                description = categories.d.results[i].Description;
                output += "<LI>" + categoryName + ":&nbsp;" +
                    description + "</LI>";
            output += "</UL>";

            document.getElementById("categories").innerHTML = output;
        else {
            var errordesc;

            errordesc = "<P>Status code: " +
                response.get_statusCode() + "<br/>";
            errordesc += response.get_body();
            document.getElementById("categories").innerHTML = errordesc;

    // Event handler for the error event.
    // Render the response body in the placeholder.
    // The body includes the error message.
    function errorHandler() {
        document.getElementById("categories").innerHTML =

However, if I change the Northwind url and use the url of my site lists (.../_api/web/lists), which is on https, I get a 403 Forbidden error. (I use this url only for testing purposes).

I think it may be a problem with https. I have read blog posts that advice to deactivate https on the sharepoint development server but it is not possible here since it is on sharpoint online. And I want to use https.

I have added the remote endpoint in the appmanifest of course.

Thank you


To access data from different site collection, you need to use SP.RequestExecutor.js file.

The sample code is present in the following msdn links:

Access SharePoint 2013 data from apps using the cross-domain library

Work with the cross-domain library across different Internet Explorer security zones in apps for SharePoint

  • Thank you. I already tried this but I had some problems with security. Then I came across this msdn.microsoft.com/en-us/library/office/…. I will give RequestExecutor another try. I think my problem had something to do with tenant administrator rights. – Meakyl Mar 31 '14 at 13:06
  • If you are having security issues, I guess second link may help. For cross domain calls in SP, we usually use SP.RequestExecutor.js. Tell me if you face any other issue – Garima Apr 1 '14 at 4:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.