Microsoft has introduced REST (Representational State Transfer) service along with SharePoint 2013. Now you can use the REST services to access data / information from SharePoint remotely, it means we can perform the CRUD operation with SharePoint data via REST service. Read more about Get started with the SharePoint 2013 REST service.
One Drive for business is a place where you can store, sync and share your work files. SkyDrive is now OneDrive, and SkyDrive Pro is now OneDrive for Business. Read more about What is OneDrive for Business?
Below are the steps to access One Drive data via REST services
- To access your OneDrive for Business library, you simply click OneDrive in the Office 365 menu bar, as shown
- Click to "Shared with Everyone" folder
- Upload a file to "Shared with Everyone" folder by drag and drop or via click to upload (in our example file name is vivek.docx)
- To use the REST API to view the information on the uploaded document, construct a URL with the following pattern:
https://YourO365DomainHere-my.sharepoint.com/personal/YourUserName_YourO365DomainHere_onmicrosoft_com/_api/web/GetFileByServerRelativeUrl('/personal/YourUserName_YourO365DomainHere_onmicrosoft_com/Documents/Shared with Everyone/vivek.docx')
- Copy and paste the above URL to your browser and system will return the xml, download and save it
To programmatically get the OneDrive for Business 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/
Note : Your app for SharePoint needs to request the right set of permissions in the app manifest to access OneDrive for Business 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 OneDrive for Business, you need a token whose target audience is https://YourO365DomainHere-my.sharepoint.com/. Also remember to encode all the query parameters in the URL.


Comments
Post a Comment