1

Here's the setup:

  1. SharePoint on premises: http://sharepoint-site.com
  2. A 3rd party web site (just an html page, no sharepoint: http://web-site.com/test.html) needs to make a call into sharepoint to retrieve a list of all available lists in the root web
  3. I created a sharepoint-hosted app (with list permissions) and installed it into http://sharepoint-site.com; its URL is http://app-c06fc375b9447b.apps.sharepoint-site.com/MyApp

http://web-site.com/test.html has the following code:

<!DOCTYPE html>

<head>
<script src="jQuery.js"></script>

<script>

        var hostweburl = "http://sharepoint-site.com/";
        var relsiteurl = ""; // leave empty if root web
        var appweburl = "http://app-c06fc375b9447b.apps.sharepoint-site.com/MyApp";


        $(document).ready(function () {
            // resources are in URLs in the form:
            // web_url/_layouts/15/resource
            var scriptbase = hostweburl + relsiteurl + "/_layouts/15/";

            // Load the js files and continue to the successHandler
            $.getScript(scriptbase + "MicrosoftAjax.js", function() {
                $.getScript(scriptbase + "SP.Runtime.debug.js",
                    function () {
                        $.getScript(scriptbase + "SP.debug.js",
                            function () { $.getScript(scriptbase + "SP.RequestExecutor.debug.js", continueLoading); });
                    });
            });
        });


        function continueLoading() {
            getDocumentList();
        }

        function getDocumentList()
        {

            var executor = new SP.RequestExecutor(appweburl);

            executor.executeAsync({
                url:appweburl + "/_api/SP.AppContextSite(@target)/web/lists?target='" + hostweburl + "'",
                method: "GET",
                headers: {  "Accept": "application/json; odata=verbose" },
                success: successHandler, 
                error:  errorHandler
            });

            function successHandler(data) {
                console.log(data);   
            }

            function errorHandler(a, b, c) {
                console.log(c);
            }           
        };  
</script>
</head>

When I load http://app-c06fc375b9447b.apps.sharepoint-site.com/MyApp I get the following error in JS console:

There is no trusted URLs configured for the app deployment.

What am I doing wrong?

1

Ok, I figured it out. In appmanifest.xml there is AppPrincipal/Internal entry; it has an optional AllowedRemoteHostUrl attribute which shoudl be set to http://web-site.com from my example

<AppPrincipal>
  <Internal  AllowedRemoteHostUrl="http://web-site.com"/>
</AppPrincipal>
  • I am having same issue but in my case its on provider hosted app. Any idea? – user12345 Aug 10 '16 at 16:31

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.