0
votes

I am developing a Office 365 Mobile App with Cordova in Visual Studio 2013. So I am using the Client Libraries.

I can authenticate to SharePoint Online using the discoveryContext

discoveryContext.services(authContext.getAccessTokenFn('Microsoft.SharePoint'))
    .then((function (capabilities) {            
        capabilities.forEach(function (v, i, a) {
            var endpointUri = v.resourceId + "sites/APIWorkspace/_api";
            if (v.capability === 'MyFiles') {
                sharePointClient = new Microsoft.CoreServices.SharePointClient(
                    endpointUri,
                    authContext.getAccessTokenFn(v.resourceId)                        
                );                    
                console.log("Connected to Sharepoint");                 
            }                
        });
    }).bind(this), function (error) {
        console.log(JSON.stringify(error));
    });

My Question is, how can I access the lists from SharePoint Online? Are there any documentations about sharepoint.js or the SharePointClient?

Thanks in Advance.

1

1 Answers

0
votes

Use files object to get the items. You can find SharePoint documentation here, there is not much JavaScript samples, it is in-process of getting updated. If you are adding O365 services through Add Connected services then you can look into services\office365\scripts\typings\sharepoint.d.ts to find different API and can easily construct the API calls.

sharePointClient.files.getItems().fetch().then(function (result) {
    result.currentPage.forEach(function (item) {
        console.log(item.type + ' "' + item.name + '"');
    });
}, function (error) {
    console.log(error)
});