Follow us on Twitter
Follow us in Facebook
Office Dev Content
SharePoint Dev Content
Blogs for Office developers > SharePoint dev blog
SkyDrive Pro, a personal cloud library for business, is a place where users can store files and documents, sync them with their devices, and share them with others. It comes as a part of SharePoint Server 2013 or SharePoint Online (Office 365). Essentially it’s a SharePoint Document Library under the covers, so you can access it just like any other document library in SharePoint 2013 using the SharePoint APIs. Whether you use the client-side object model (CSOM) or Representational State Transfer (REST)—it’s your choice. In this post, learn how to construct the REST URLs to access files and folders in SkyDrive Pro.
From a user’s perspective, to access your SkyDrive Pro library, you simply click SkyDrive in the Office 365 menu bar, as shown in Figure 1.
Or you can always navigate directly there using this URL pattern: https://YourO365DomainHere-my.sharepoint.com/personal/ YourUserName_ YourO365DomainHere_onmicrosoft_com/.
But that’s from the end-user perspective. How do you access SkyDrive Pro as a developer? In this example, we will use REST.
Note: If your Office 365 site is set up to use a custom domain—for example, contoso.com—your MySite URL will be of the pattern, https://contoso-my.sharepoint.com/personal/YourUserName_ contoso_com/.
The above URL patterns show how to construct the REST calls for use in the browser for simplicity. However, you can readily implement these URL patterns in your code.
For example, if you are developing an app for SharePoint, the app can call into a user’s MySite site collection and access their SkyDrive Pro documents using REST or CSOM.
The REST call to get to the file would be: https://YourO365DomainHere-my.sharepoint.com/personal/ YourUserName_YourO365DomainHere_onmicrosoft_com/_api/web/ GetFileByServerRelativeUrl('/personal/YourUserName_YourO365DomainHere_onmicrosoft_com/ Documents/Shared%20with%20Everyone/myDocument.docx')/$value
To programmatically get the SkyDrive Pro URL for the signed-in user, you can make a call to the user Profile service: https://YourO365DomainHere-my.sharepoint.com/_api/ SP.UserProfiles.PeopleManager/GetMyProperties/personalURL/
Remember, your app for SharePoint needs to request the right set of permissions in the app manifest to access SkyDrive Pro content—for example, AllSites.Read—and if using the User Profile service: Social.Read. When you request a token from Access Control Service (ACS), make sure you have the right audience. In order to call SkyDrive Pro, you need a token whose target audience is https://YourO365DomainHere-my.sharepoint.com/. Also remember to encode all the query parameters in the URL.
This post does not detail these calls for CSOM, but the CSOM equivalents are available: see the CSOM, JSOM, and REST API Index. Other valuable resources are the articles on how to complete basic operations using CSOM and JSOM, and getting started with SharePoint 2013 REST.
Yina Arenas, Program Manager, APPS PM
Donovan Follette, Sr. Technical Evangelist, Developer & Platform Evangelism