0

From a remote web app(plain ASP.NET), I am trying to read the data from an office365 SharePoint site using JSOM. I am using the following code

                var siteUrl = "https://spdev101365.sharepoint.com/sites/DevedsloperSite"; //For the moment just hard coding this
                var ctx = new SP.ClientContext(siteUrl);
                var factory = new SP.ProxyWebRequestExecutorFactory(siteUrl);
                ctx.set_webRequestExecutorFactory(factory);

                var oList = ctx.get_web().get_lists().getByTitle('MyCustomList');
                var query = new SP.CamlQuery(); //The Query object. This is used to query for data in the List
                query.set_viewXml('<View><RowLimit></RowLimit>10</View>');

                var collListItem = oList.getItems(query);

                ctx.load(oList); //Retrieves the properties of a client object from the server.
                ctx.load(collListItem);

                ctx.executeQueryAsync(Function.createDelegate(this, this.successHandler), Function.createDelegate(this, this.errorHandler));

My First quest is, is this possible in the first place? and if so what am I missing here (I get an authentication failure message).

  • 1
    I don't think it is possible because of Same Origin Policy, not even through app policy, you need a proxy. But I just have to ask, how did you get access to SP in your JavaScript if you have a plain APT.NET site? – eirikb Apr 6 '15 at 10:36
  • I got access by just adding the required javascript (sp.js and so on) as references. – user39707 Apr 7 '15 at 4:13
  • Just referring them from the SharePoint site then? I thought at least some of the sp-scripts depended on the dynamic inline scripts on the page – eirikb Apr 7 '15 at 5:24
0

Yes, You can get the list items using REST.

url: http://site url/_api/web/lists/GetByTitle(‘Test')/items
method: GET
headers:
    Authorization: "Bearer " + accessToken
    accept: "application/json;odata=verbose" or "application/atom+xml"
| improve this answer | |

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.