Select a language to translate this page!
Powered by Microsoft® Translator
This post has been updated to correct an error in the example showing how to upload a text file via HTTP POST.
With the announcements on Windows Store we wanted to share new work we were doing to help developers on Windows, Windows Phone and other platforms use SkyDrive in their applications. A few months ago as part of the preview of Windows Live for Windows 8, we announced the availability of the developer preview, the next version of the Live Connect APIs and the newly created Live SDK. A major change to the API was to address feedback we’d gotten from developers about access to SkyDrive. The primary change for SkyDrive was providing the ability for applications to fully access, upload and share documents, photos and videos from a user’s cloud storage in SkyDrive.
With the integration into Windows Phone and Windows 8, SkyDrive is a key part of your “device cloud,” letting you work and play easily across your PC and phone. SkyDrive also works with apps like Microsoft Office and OneNote so you can organize, collaborate and share from anywhere. We believe that the most value for our customers comes when more people and more apps can connect to the cloud from most available devices. This goes beyond device platforms and applications built by Microsoft. With this API change, any app on any platform now gets to take advantage of the fact that any user with a Windows Live ID, including every Windows 8 user, has free cloud storage in SkyDrive that they can integrate into their experience to access their documents and photos.
I’m happy to announce that the new version of the Live Connect APIs and the Live SDK for Windows Phone has now shipped. Please read on to learn more about what’s available now, or visit the Live Connect developer center to get even more details.
The Live Connect REST API provides an intuitive hierarchical model of a user’s content that is tied to their Windows Live ID. This hierarchy is shown below:
The dark blue squares are the new aspects of the data model added with this new release. The first change for SkyDrive is that there is now a way to access a user’s entire SkyDrive using a REST API call.
Here is a sample HTTP request to retrieve a list of a user’s entire set of folders in SkyDrive:
GET https://apis.live.net/V5.0/me/skydrive/files?access_token=ACCESS_TOKEN HTTP/1.1User-Agent: FiddlerHost: apis.live.net!--crlf-->!--crlf-->
GET https://apis.live.net/V5.0/me/skydrive/files?access_token=ACCESS_TOKEN HTTP/1.1
User-Agent: Fiddler
Host: apis.live.net
The above request returns the following JSON result set for my SkyDrive account: !--crlf-->
{"data": [ // 1 item{"id": "folder.616444ee7a34f417.616444EE7A34F417!12045","from":{"name": "Dare Obasanjo","id": "616444ee7a34f417"},"name": "Wave 4 Feedback","description": null,"parent_id": "folder.616444ee7a34f417","upload_location": "https://apis.live.net/v5.0/folder.616444ee7a34f417.616444EE7A34F417!12045/files/","count": 14,"link": "https://skydrive-df.live.com/redir.aspx?cid=616444ee7a34f417&page=view&resid=616444EE7A34F417!12045&parid=616444EE7A34F417!1967","type": "album","shared_with":{"access": "Everyone (public)"},"created_time": "2010-07-14T13:28:48+0000","updated_time": "2011-07-18T03:40:07+0000"}]}!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->
{
"data": [ // 1 item
"id": "folder.616444ee7a34f417.616444EE7A34F417!12045",
"from":
"name": "Dare Obasanjo",
"id": "616444ee7a34f417"
},
"name": "Wave 4 Feedback",
"description": null,
"parent_id": "folder.616444ee7a34f417",
"upload_location": "https://apis.live.net/v5.0/folder.616444ee7a34f417.616444EE7A34F417!12045/files/",
"count": 14,
"link": "https://skydrive-df.live.com/redir.aspx?cid=616444ee7a34f417&page=view&resid=616444EE7A34F417!12045&parid=616444EE7A34F417!1967",
"type": "album",
"shared_with":
"access": "Everyone (public)"
"created_time": "2010-07-14T13:28:48+0000",
"updated_time": "2011-07-18T03:40:07+0000"
}
]
Uploading files is similarly straightforward. Applications can use either HTTP PUT or POST requests to upload documents, photos or videos to SkyDrive at the folder’s upload location. It should be noted that not all file formats are supported for upload to SkyDrive. In this release, we’ve focused on supporting the types of content our users can easily preview on SkyDrive.com.
Below is an example of uploading a text file using HTTP PUT:
PUT https://apis.live.net/v5.0/me/skydrive/files/HelloWorld.txt?access_token=ACCESS_TOKEN Hello, World!!--crlf-->!--crlf-->
PUT https://apis.live.net/v5.0/me/skydrive/files/HelloWorld.txt?access_token=ACCESS_TOKEN
Hello, World!
and here’s what the same upload looks like using HTTP POST:
POST https://apis.live.net/v5.0/me/skydrive/files?access_token=ACCESS_TOKEN Content-Type: multipart/form-data; boundary=A300x --A300xContent-Disposition: form-data; name="file"; filename="HelloWorld.txt"Content-Type: application/octet-stream Hello, World!--A300x--
POST https://apis.live.net/v5.0/me/skydrive/files?access_token=ACCESS_TOKEN
Content-Type: multipart/form-data; boundary=A300x
--A300x
Content-Disposition: form-data; name="file"; filename="HelloWorld.txt"
Content-Type: application/octet-stream
--A300x--
These are just a few examples of how easy it is to interact with SkyDrive using nothing but regular HTTP. Other operations such as editing, copying or sharing files are similarly straightforward. For an easy way to try the Live Connect REST API for yourself, visit our interactive SDK.
The goal of the Live SDK is to simplify common tasks that all applications have to perform using the Live SDK. These tasks include creating a sign-in button, requesting and obtaining consent from the user to access their data via OAuth 2.0, and working with the Live Connect REST API.
Since we provided the developer preview for the Live SDK for Windows Phone, we have seen a lot of interest in it on our developer forums, which has been very exciting to see.
To help developers get started using the Live SDK for Windows Phone, we’ve created a code sample called Photo Sky on the Go that shows how to browse photo albums on SkyDrive and upload photos from the Pictures hub or the Camera. This sample incorporates a number of simplifying elements such as the a standard sign-in control that can be placed in the XAML for your Windows Phone app and that handles the sign-in and consent process. The following XAML specifies that a sign-in button will be created, which provides the ability to sign the user in to get access to their profile, photos and upload content to SkyDrive:
<live:SignInButton ClientId="YOUR CLIENT ID GOES HERE" Scopes="wl.basic wl.photos wl.skydrive wl.offline_access wl.signin wl.skydrive_update" RedirectUri="http://oauth.live.com/desktop" Branding="Skydrive" TextType="SignIn" Grid.Row="1" Margin="114,8,145,8" d:LayoutOverrides="VerticalAlignment" SessionChanged="SignInButton_SessionChanged"/>!--crlf-->
<live:SignInButton ClientId="YOUR CLIENT ID GOES HERE" Scopes="wl.basic wl.photos wl.skydrive wl.offline_access
wl.signin wl.skydrive_update" RedirectUri="http://oauth.live.com/desktop" Branding="Skydrive" TextType="SignIn"
Grid.Row="1" Margin="114,8,145,8" d:LayoutOverrides="VerticalAlignment" SessionChanged="SignInButton_SessionChanged"/>
The button when created looks as shown in the image below:
Clicking on the button takes the user through the OAuth 2.0 based permission flow, where the user has the opportunity to accept or decline the request to give the application access to their SkyDrive.
Once this is done, the application can now download and upload content to SkyDrive using the LiveConnectClient class . The code excerpt below shows the process of browsing photo albums in SkyDrive using the Live SDK in the Photo Sky on the Go app.
private void GetAlbumData() { LiveConnectClient clientFolder = new LiveConnectClient(App.Session); clientFolder.GetCompleted += new EventHandler<LiveOperationCompletedEventArgs>(clientFolder_GetCompleted); clientFolder.GetAsync("/me/albums"); } void clientFolder_GetCompleted(object sender, LiveOperationCompletedEventArgs e) { if (e.Error == null) { List<object> data = (List<object>)e.Result["data"]; foreach (IDictionary<string,object> album in data) { SkydriveAlbum albumItem = new SkydriveAlbum(); albumItem.Title = (string)album["name"]; albumItem.Description = (string)album["description"]; albumItem.ID = (string)album["id"]; Albums.Add(albumItem); GetAlbumPicture(albumItem); DownloadPictures(albumItem); } } }!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->
private void GetAlbumData()
LiveConnectClient clientFolder = new LiveConnectClient(App.Session);
clientFolder.GetCompleted += new EventHandler<LiveOperationCompletedEventArgs>(clientFolder_GetCompleted);
clientFolder.GetAsync("/me/albums");
void clientFolder_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
if (e.Error == null)
List<object> data = (List<object>)e.Result["data"];
foreach (IDictionary<string,object> album in data)
SkydriveAlbum albumItem = new SkydriveAlbum();
albumItem.Title = (string)album["name"];
albumItem.Description = (string)album["description"];
albumItem.ID = (string)album["id"];
Albums.Add(albumItem);
GetAlbumPicture(albumItem);
DownloadPictures(albumItem);
Below is the screenshot of the user experience for the above code:
The code for uploading photos from the phone is similarly straightforward:
internal void Upload() { PhotoChooserTask task = new PhotoChooserTask(); task.ShowCamera = true; task.Completed += new EventHandler<PhotoResult>(task_Completed); task.Show(); } void task_Completed(object sender, PhotoResult e) { if (e.ChosenPhoto == null) return; LiveConnectClient uploadClient = new LiveConnectClient(App.Session); uploadClient.UploadCompleted += new EventHandler<LiveOperationCompletedEventArgs>(uploadClient_UploadCompleted); uploadClient.UploadAsync(SelectedAlbum.ID, "Image"+DateTime.Now.Millisecond+".jpg", e.ChosenPhoto); } void uploadClient_UploadCompleted(object sender, LiveOperationCompletedEventArgs e) { if (e.Error == null) { Deployment.Current.Dispatcher.BeginInvoke(() => DownloadPictures(SelectedAlbum)); } }!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->!--crlf-->
internal void Upload()
PhotoChooserTask task = new PhotoChooserTask();
task.ShowCamera = true;
task.Completed += new EventHandler<PhotoResult>(task_Completed);
task.Show();
void task_Completed(object sender, PhotoResult e)
if (e.ChosenPhoto == null)
return;
LiveConnectClient uploadClient = new LiveConnectClient(App.Session);
uploadClient.UploadCompleted += new EventHandler<LiveOperationCompletedEventArgs>(uploadClient_UploadCompleted);
uploadClient.UploadAsync(SelectedAlbum.ID, "Image"+DateTime.Now.Millisecond+".jpg", e.ChosenPhoto);
void uploadClient_UploadCompleted(object sender, LiveOperationCompletedEventArgs e)
Deployment.Current.Dispatcher.BeginInvoke(() => DownloadPictures(SelectedAlbum));
The above code uses the PhotoChooserTask to select a photo from the phone’s Pictures Hub or Camera, which is then uploaded to SkyDrive using the LiveConnectClient class.!--crlf-->
That’s all there is to it.
For Windows developers, there’s also a Live SDK for Windows Developer Preview which was previously discussed by Mike Torres in his blog post Extending "Windows 8" apps to the cloud with SkyDrive. That SDK will be updated along with future releases of Windows and will go live when the next version of Windows is finally released.
We’re really encouraged by the enthusiasm we’ve seen for SkyDrive, both from users and developers who’ve talked to us about what they want from our platform. With the availability of the APIs, we’d love to see the innovative ways people incorporate SkyDrive into their mobile apps, devices and websites.
Thanks a lot for all the feedback. It’s always appreciated and we are always listening.
Dare Obasanjo
Lead Program Manager, Live Connect Platform
Good work! Can't wait to start bulding things with this :) !
Dare,
One area where Office Web Apps is lagging behind Google Docs is in the provision of an API. For example, here (cwebbbi.wordpress.com/.../using-google-docs-data-explorer-and-powerpivot-for-questionnaires) is a blog post published just today by Chris Webb in which the use of the Excel web app would have been an obvious choice but the author was forced to go with Google Docs simply because it has an API plus Google Forms.
Chris and I have long been proponents of an API for the Excel web app and have discussed it at length on this forum thread: answers.microsoft.com/.../eaa565f1-83b6-4e7c-a1ec-af31fc3d7a73
I don't know if such an API would fall under your remit (given that the docs exist on SkyDrive) or the remit of the web apps team but clearly you guys talk to each other a lot so if you could bash your heads together and come up with a way of enabling similar scenarios to those possible with Google Docs I for one would be very grateful.
Thanks
@Jamiet
Check out Handyscan for Windows Phone 7 uses this api to upload scanned documents to Skydrive.
handyscan.jdbpocketware.com
Without the possibility to upload more file types (in my case SQLite and XML) I cannot make use of Skydrive and have to rely on Dropbox, sorry. The SQLite database contains personal user data, not application data, so it makes perfect sense to store it on Skydrive. So please allow more file types or better, remove the file type limitation completely, as you could never know about all possible scenarious.
Let's face it. Windows is complicated and uncool. Google, Facebook, Twitter and Apple grab the headlines for innovation and ease of use.
Everyone on this post is in the 5%, maybe even 1% of people that really (technically) understand Windows. You get it. Ever try to teach a newbie how to use Windows from scratch or explain that re-formatting your harddrive and starting over with a clean install of windows is the best course action....step-by-step. Or migrating your apps and data to a new PC... step by step? Almost impossbile.
Windows Live represents Microsoft's path to becoming relavent again--but the vision is weak.
Let me illustrate. Windows with its DLL's files and registry entires make it extremely difficult to be recoverable, upgradeable and transportable. While these technologyies were fantastic in the early 1990's to make Windows extensiable for 3rd parties--I better not ever have to upgrade my PC or OS or start over--because that is impossible without a clean back-up of my data and the ability to re-install all my applications. Do know how difficult that is for the 95%?
Why is switching to MAC or other OS based solution a big considered when buying a new PC or having to recover from corrupted system?
The Win OS, applications, data, binaries (hardware drivers) and profile data all require specialized knowledge and experience to back-up, re-install and support. The user experience for managing these separate layers is: Dig through Knowledge bases, appling technical skill and knowledge with commands following many, many steps consuming hours and hours.
What if....
Windows Live was able to solve that problem?
If Windows Live could capture an image of our PC that could be reloaded
If Windows Live could background upload our files to the cloud
If Windows Live had an APP STORE that kept a record of our applications for re-installation
If Windows Live could background sync our profile and restore points for restore
If Windows Live would do these things....Microsoft would become relvent again. Their stock price might even more up.
The cool companies get it and are racing towards to new computing model. Microsoft's cloud offering is relvant to businesses but very basic for consumers. Like Windows....Windows Live is slow moving, difficult to use and missing so many features it is not that compelling or interesting. Moreover, Windows Live is not a strategy for making the Windows User experience outstanding and for solving some of Windows biggest issues.
Will people be using Windows in 10 years? Will we care about Windows Live in 10 years?
@JDB nice job with Handyscan! Just purchased the premium version. Works great with SkyDrive! Suggestion: don't automatically create the backup folder in the root. I would suggest root\Handyscan\backups
Could SkyDrive be extended to other mobile operating systems? Right now, only OneNote for iOS appears to be able to sync to the cloud outside of Windows Phone. Windows Phone presence is very light on Verizon and Sprint. Verizon (my current carrier) not only doesn't carry the HTC Trophy in store anymore, but it seems the sales associates, including the store manager, have been given instructions to throw Android in customer's faces and to encourage customers to actually avoid Windows Phone simply because it's from Microsoft and that Microsoft HAD such a bad user experience on Windows MOBILE so it must be bad on Windows Phone. This is ignorant and Microsoft doing little to turn that tide is going to make it difficult for users to even be open to considering purchasing a Windows Phone device in the future. But, even as great as Windows Phone is, the Windows Live cloud based services should be extended across as many platforms as possible, so long as the user experience does not fracture like is now with only OneNote for iOS being available outside of Windows Phone. Keep up the improvements to SkyDrive!
@jamiet - the new Excel Web services JavaScript API do any of what you're looking for? www.excelmashup.com for examples and documentation...
As a file system developer I always wonder when I see a new REST API for file system access why the REST API isn't hidden from developers. Why should developers need to learn a new REST API for every file system that the application wants to support? Apps should access file systems as file systems. We don't ask applications to implement the dirty details of accessing NTFS, NFS, AFS or Lustre. Why expose the raw RPCs for accessing cloud storage?
Sample code linked does not work need to change e.Session.Status to e.Status due to new SDK changed. under SignInButton_SessionChanged
To update I am talking about WP7 Sample
@Nishant,
Thanks for reporting this. We'll update the code sample as soon as possible.
It's really great but missing To-Do API.
Hi
Great work, but I am wondering if it is possible to enumerate also files, not only the albums?
Or, does every app get a folder?
What I want is to store data from my app into skydrive as backup.
This has great potential but still so confusing.
Can someone create a video that emcompases start to finish including creating app account.
I tried running the example project and it tells me the client does not exit and I should go to https://manage.dev.live.com/. But when I go to the link mentioned I see the apps that I just created.
@AlonsoRodriguez
Did you specify the client ID you created on http://manage.dev.live.com in the sign-in control within the XAML for the login page of your app?
@ Dare Obasanjo
Thanks, That was it.
Now when I click "Yes" on the allow access screen it just takes me back to profile and album but nothing is loaded.
@Alonso - DId the profile screen get populated with any data. Can you check if the the App.Session property in app.xaml.cs is getting populated after you click yes.
@deepeshm
The profile page did not populate.
But looking at the error message it said I needed to set my app as a mobile app.
Once I did that it worked.
THANKS
One more question.
Before I start digging too much into it, this sample could be modified to download and upload txt files?
Storing docs and photos is for such a limited set of apps. No instead give me an API for storing app settings. The roaming settings API in Win8 is absolutely amazing, but it will never get truly amazing until I can access those settings from my phone app. It would enable every developer out there to easily create continuous clients/companion apps.
The diagram at the top of this blog post suggests that the Live SDK for Windows Phone supports the Calendar but there is no mention of it later in the post. Is Calendar a first class citizen of the API alongside SkyDrive?
@ AlonsoRodriguez - Yes, you can. I started off by getting the albums but you can switch it to folders easily.
I submitted my WP7 app using that skydrive button. I got a certification failure saying - "The SkyDrive logo is used in the application. Please provide details in the "notes" section of the application submission form
if you have received permission to use the logo, or remove from subsequent submissions."
Now, how to get the permission from MS to use that logo as it is by default provided by that LiveSignInButton.
Is there any way to change the logo for button or how to convince WP7 app certify guys that its legitimate to use the logo with skydrive sdk.
Thanks in advance for quick help !!
@Nishant Rana,
Sorry for any inconvenience here. We are working with the Windows Phone marketplace team to ensure that there is less confusion around legitimate usage of the branding marks related to Live Connect.
Can you please resubmit your app and mention in the notes that
1.) You are using the official SDK for working with SkyDrive available from http://dev.live.com which is responsible for creating sign-in experiences which may contain the SkyDrive logo.
2.) You are in conformance to the Live Connect branding guidelines at msdn.microsoft.com/.../ff796187 (after confirming that you are)
3.) Also mention that any questions about the guidelines should be sent to dareoATmicrosoftDOTcom before rejecting the application again.
Thanks.