1

Having trouble finding a clear answer on this but can I do REST calls to a library across Site Collections within the same domain?

So if I have mysite.com/r/Site1 and mysite.com/r/Site2

Given permissions on Site 1 are set to everyone in the AD can read. Will I be able from Site 2 to return documents from a list in Site 1 using the REST API?

I know I can use the Search API but I'm curious about REST

  • 1
    You asked 2 hours ago.. you could have found the answer yourself with a quick try. Yes, if the user can access a SiteCollection then the user can call any endpoints in that SC – Danny '365CSI' Engelman Mar 16 '17 at 17:56
  • I'm not in an environment where I have access to create site collections so I couldn't thanks. Anyways, thanks for the answer. – Batman Mar 16 '17 at 19:49
  • You don't have to create site collections to test... You could've simply opened IE/Chrome dev tools and did a quick test and had an answer in less than five minutes... – wjervis Mar 17 '17 at 11:08
3

If the both Site Collections are under the same hostname (for example https://my.site.com for both of them), and if the user has the correct permissions, then yes you can use REST.

0

Call below function in site1.

siteUrl is url of your second site listName is name of list from which you want to get detail.

function getListItem(siteUrl, listName) {
    $.ajax({
        url: siteUrl + "/_api/web/lists/getbytitle('" + listName + "')/items",
        type: "GET",
        contentType: "application/json;odata=verbose",            
        headers: {
            "Accept": "application/json;odata=verbose",
            "X-RequestDigest": $("#__REQUESTDIGEST").val()
        },
        success: function (data) {
            console.log(data.d);
        },
        error: function (data) {

        }
    });
}

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.