0

I am trying to make a simple query to user’s personal site from any site collection on the tenant, however, I am getting error: Unexpected response data from server.

I’ve tried both with REST and JSOM to open context, but both cases I am receiving this error.

When executing the code against another context / another site collection, I am able to execute queries against it.

What is so special about the personal user’s site?

Some example code:

// I’ve tried context to be either current site collection

// _spPageContextInfo.webAbsoluteUrl or personal site’s URL $.getScript(SharePoint.Helpers.combineUrls(context, “_layouts/15/SP.RequestExecutor.js”), function () { var executor = new SP.RequestExecutor(context); executor.executeAsync({ url: targetUrl, // https://tenant-my.sharepoint.com/personal/user_domain_com/_api/web/lists method: “GET”, headers: { “accept”: “application/json;odata=verbose”, }, success: typeof (onSuccessFunc) === “function” ? onSuccessFunc : function (data) { window.console && console.log(JSON.parse(data.body)); }, error: typeof (onErrorFunc) === “function” ? onErrorFunc : function (err) { alert(JSON.stringify(err)); } }); });

var clientCtx = new SP.ClientContext(personalSiteUrl);var web = clientCtx.get_web();
clientCtx.load(web);
clientCtx.executeQueryAsync(function () { alert ("web site url:" + web.get_url()) }, function () { console.log("FAIL")});

 

(Visited 50 times, 1 visits today)
Add a Comment