Category Archives: Skydrive

Access SkyDrive Pro using the SharePoint 2013 APIs

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.

Figure 1. Office 365 menu bar
Figure 1. Office 365 menu bar

Or you can always navigate directly there using this URL pattern:
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,—your MySite URL will be of the pattern, contoso_com/.

Start with the basics

  1. Sign in to your Office 365 SharePoint site, and navigate to your SkyDrive Pro library using one of the two methods mentioned above.
  2. Click the Shared with Everyone folder and upload a document. For this example, the document name is myDocument.docx.
  3. To use the REST API to view the information on the uploaded document, construct a URL with the following pattern:
    Documents/Shared with Everyone/myDocument.docx’)
  4. Copy/paste it into your browser. The XML returned should look like this:
    Figure 2. Example of XML returned by the REST APIFigure 2. Example of XML returned by the REST API
  5. To download the document, append /$value to the URL. When prompted to save the file, name it myDocumentDownload.docx, and save it.

Work with documents and other files as “items”

  1. For definitive read/write guidance, see Working with lists and list items with REST on MSDN.
  2. To experiment, upload a couple of files to the root Documents folder in your SkyDrive Pro library. Now you can test out a few REST read calls in your signed-in browser.
  3. Using this URL pattern:
    Append lists/Documents/items/ to it. Here you will get all the items.

    1. To get the metadata for a particular item, modify items/ to items(n)/ where (n) is the specific item number you want to view.
    2. To see the metadata for the file, append file/ (for example, items(n)/file/)
    3. To download the file, append $value (for example, items(n)/file/$value)
  4. You can also use in place of the above pattern lists/GetByTitle(‘Documents’)/…, and the API will return the same results.

Work with folders and files

  1. Files are often nested in folders, and you may need to drill down into the folder structure; or you may want to represent the folder structure and files in a user interface (UI). Using the following REST calls, you can also work with folders and files in a more logical way than just the “items(n)sequential location as the pattern shown above. This is where getting folders by relative URL and subsequently enumerating all the files within a folder is really handy.
    For definitive read/write guidance, see Working with folders and files with REST on MSDN.
  2. Assume the SkyDrive file structure shown in Figure 3, where you have both folders and documents at the same level.
    Figure 3. SkyDrive file structure with folders and documents at the same level
    Figure 3. SkyDrive file structure with folders and documents at the same level
  3. To retrieve all the folders, you will use GetFolderByServerRelativeUrl with the following URL pattern:
    To this URL, append GetFolderByServerRelativeUrl(‘/personal/YourUserName_YourO365DomainHere_onmicrosoft_com/Documents’)/folders/.
    All the folders will be returned. You can then subsequently use the ServerRelativeURL property for each folder to continue to “walk down” each folder until you reach its end node.

    Figure 4. ServerRelativeUrl property of a folderFigure 4. ServerRelativeUrl property of a folder
  4. Likewise, if you want to return metadata about all the files in a folder, simply replace folders/ with files/, and all the files will be enumerated.
    Figure 5. ServerRelativeUrl property of a file
    Figure 5. ServerRelativeUrl property of a file

    Then, if you want to retrieve the file, use the GetFileByServerRelativeUrl URL pattern, described in the first section above, with /$value appended to the URL.

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:

To programmatically get the SkyDrive Pro URL for the signed-in user, you can make a call to the user Profile service:

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 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.

Lastly, for sample code, download the Apps for SharePoint sample pack, which provides examples across C#, REST, and JavaScript. It contains useful samples, including:


Microsoft Is Offering OneDrive Cloud Storage For Microsoft, iOS and Android Devices

Microsoft on Wednesday officially announced the global availability of its rebranded cloud storage service OneDrive.

Microsoft originally called the service SkyDrive but was forced to rebrand after British Sky Broadcasting sued and won a trademark lawsuit over use of the name.

OneDrive features some changes, including automatic camera backup for Android and the ability to share and view videos just as easily as photos. However, the biggest improvement is that now people can simultaneously access and edit files stored in OneDrive. The feature brings it into line with Google Drive and Apple’s iCloud. It will also automatically encode your uploaded videos and automatically stream in the optimum resolution for the bandwidth and device accessing it.

The company has also added new ways for you to earn more storage – on top of the 7 GB it is already give you for free. Microsoft is offering users who refer friends up to 5 GB (in 500 MB increments) for each friend who accepts an invitation to OneDrive, and will even give you 3 GB just for using the camera backup feature. There’s even a new monthly payment plan.

Existing SkyDrive users access the OneDrive they will find that many things are exactly as they left them. They can still log in to access web app versions of Word, Excel and PowerPoint for on-the-fly document editing.

OneDrive is built into the latest versions of Windows, Windows Phone, Office and Xbox. For everyone else, accessing SkyDrive will automatically reroute a smartphone or tablet to OneDrive landing page instead.

To celebrate the official launch of OneDrive, Microsoft will give 100,000 people 100 GB of free storage for one year.Image

Microsoft officially launches OneDrive!!

Not too long ago, Microsoft confirmed they are rebranding the SkyDrive and it will be known as OneDrive. Recently, the Redmond-based company took the wraps off of their new service, and it’s now available for the general public. For those of you who don’t know, it’s still the same as Skydrive and gives users the ability to store their files in the cloud and access them from any device, anywhere.

If you’re wondering about the files that were saved on SkyDrive, fret not as they are moved to the new cloud storage service, all you need to do is login with your SkyDrive account on OneDrive, and Voila! your files are there.

The new service comes with enticing new features as well. On signing up on the new service, users get 7GB extra storage space for free. It doesn’t end here, on referring your friends and other people, you can get an additional 5GB of storage space for every friend that registers on OneDrive. Other features include automatic camera backup for Android and you also get an extra 3GB for it, ability to share and view videos, and much more.

The service has dedicated applications for all major platforms that are currently available in the market, including Windows, Windows Phone, Xbox, iOS and Android, which makes sure you can have seamless access to the service any time.Image