0

I have the site (based on SharePoint 2013), for example https://test.com and I have my sites which are working in another domain https://my.test.com.

My task is to get data from a list which is located on site.com and display that data on my.test.com/Person.aspx.

I am using REST API. To resolve cross-domain request I decided to use the SharePoint cross-domain library (SP.RequestExecutor):

JavaScript:

var re = new SP.RequestExecutor("https://test.com");
re.executeAsync({
    url: "https://test.com/_api/web/Lists(guid'<list_guid>')/items";
    method: "GET",
    headers: {
        "Accept": "application/json; odata=verbose"
    },
    success: function(response){ console.log("success!"); },
    error: function(e){ console.log("fail!"); }
})

But the executeAsync() function returns an object with undefined fields:

JavaScript:

{
    allResponseHeaders: undefined
    binaryStringResponseBody: undefined
    body: ""
    contentType: undefined
    headers: null
    responseAvailable: false
    state: undefined
    statusCode: undefined
    statusText: undefined
}

How did I tried to fix this?

1) I tried to use the digest value in headers of my request and add parameter but it did not help.

xhrFields: { withCredentials: true }

2) Also I tried to use another URL:

https://test.com/_api/SP.AppContextSite(@target)/web/Lists(guid'<list_guid>')/items?@target='https://my.test.com'

But the result is the same - empty object.

I am testing my request at https://my.test.com/Person.aspx (my browser is MS Edge).

What am I doing wrong?

Please, help me.

  • You should look at the response object, not the return from executeAsync – Robert Lindgren Sep 26 at 9:22

Your Answer

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

Browse other questions tagged or ask your own question.