3

I am facing an issue while using CSOM in SharePoint 2013. I have configured an alternate access mapping for our site to run on http://mycustomdoamin.net/ The site is running fine and I am able to see the pages.

Now I am trying to use CSOM to get the current SP context and execute a query. At that point, I am getting error:

Unexpected data from server

On investigating with Fiddler, I found that SharePoint is making a call to http://mycustomdoamin/_api/contextinfo.

Note that the above is NOT the FQDN that I have configured my site for. It is missing the .net domain extension. Consequently, I am getting a 502 DNS lookup failed error.

The same script works fine when running without the mapping (e.g. on http://ServerName ). I have also tried setting up hosts file entry for the domain but that too doesn’t work.

What am I doing wrong here?

1 Answer 1

0

I have the same problem but in my case I'm using Office365 and with and with a site collection that isn't is the root of sitecollection (/sites/mysite).

I'm not sure about the problem but when I whatch the variable with the SP.ClientContext.get_current() value I have showed that the "$u_0" property has the value "https://mysubscription.sharepoint" so when CSOM try to make the calls it has the same error.

I have founded two solutions that dependeds of your solutions:

The first option, set the "$u_0" property before you call the executeQueryAsync method. For example:

function FixContext(Context) {
if (Context.$u_0.indexOf(".sharepoint") > 0)
    if (Context.$u_0.indexOf(".com") < 0)
        Context.$u_0 += ".com";

return Context;}

The second option consist on use the "_spPageContextInfo" variable:

_spBodyOnLoadFunctionNames.push("InitializeObjects_fromPagecontextInfo");

function InitializeObjects_fromPagecontextInfo() {
RelativeSiteUrl = _spPageContextInfo.siteServerRelativeUrl;}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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