>> Hi. I'm Jeremy Kelley,
Senior Program Manager on
the OneDrive and SharePoint Developer Platform team.
Whether you're building solutions targeting Office 365
or building an integration for consumer OneDrive,
Microsoft Graph offers an easy and consistent API
that you can use to access data.
Today, I'm going to walk through
the basics of what OneDrive and
SharePoint offer you through Microsoft Graph,
solve the actions you can take on your data,
and of course, where you should go to get started.
Before we dive into the APIs,
I want to share with you some resources that I find
incredibly helpful when I'm working
with Microsoft Graph myself.
Whenever I'm working with Graph,
this is my starting point for the day and
it's home to my favorite resources,
the Graph Explorer and the Documentation.
Graph Explorer is a tool I'll be using to show you what's
possible with the OneDrive and
SharePoint APIs and Microsoft Graph.
It's a great collection of sample
code and lets you try out
your Graph calls in a framework
and environment-agnostic way.
The Documentation is something I always have handy,
whether I'm looking up the parameters I can
pass to a Graph call
or just looking at what data is available to
me, Documentation is indispensable.
You may be thinking of OneDrive as
the place to store your personal files.
In my case, it's my music collection.
Or you might immediately think of
OneDrive for Business where you can
store all your work files.
Both of those are great answers
but since we're developers,
the answer is, of course, more nuanced than that.
In the Microsoft Graph,
OneDrive is primarily represented
by drives and drive items,
and importantly, drives are everywhere files exist.
So the traditional space as I already
mentioned, those are drives.
Team sites in SharePoints, those have drives.
Groups or teams, those have drives, too.
Let's take a look at some of the ways that we can
get a drive and look at its contents.
The first thing I'm going to do is add
the OneDrive and SharePoint samples
that we're going to use to the sample list.
I could do that by
clicking on "Show more samples,"
and just switching them on.
With Graph Explorer, I can either use
a set of sample data we provide or
I could sign in and use my live data
which is great when I'm experimenting or debugging.
We're going to stick with the sample data today.
One of the most basic things I might want to
do is get the list of files in my drive.
If we take a look at what Graph Explorer just did for us,
it populated a URL into the bar on
top and gave us the results
and the response preview below.
If I were doing something more complicated,
I could provide the body of
the request and even the headers.
Looking at the URL it provided,
there are a few important components to look at.
After the version specification, it includes /me/drive.
That tells Graph that I want my drive regardless of path.
Even better, it doesn't matter whether I'm logged into
my OneDrive for Business or OneDrive personal account.
It will return me
the right drive based on my user context.
Looking down at the sample data,
I can see in the web URL and in
the parent reference that
this is OneDrive for Business data.
But for most operations,
that won't matter to me when I'm
programming against the API.
Each of the items shown in the data,
whether it's a folder or a file, is a drive item.
Most of the actions I might want to
do tend to be things I do on a drive item.
I can upload and download files,
get sharing links, modify permissions, and much more.
Check the Documentation to find
more things you can do and
be sure to let us know on User Voice
if there's something you want to do,
but you don't see available.
The next two samples in the list show me
some really useful things that start
to add some intelligence to my integrations.
I can get the files I've recently
used or the files that have been shared with me.
In both of these cases,
the files may not actually live inside of
my drive but that doesn't
matter because if we look at the data,
I'm going to see a remote item section that
allows me to access the file wherever it lives,
even if it's a reference.
In some cases, my drive items may have
additional facets of information based on their type.
For example, photos or videos will have extended
properties that I can read that are type specific.
Now that we know that we can get files and folders,
let's talk about SharePoint.
SharePoint is many things to many people.
It's a place you go to collaborate in team sites.
It's a place you go to find your
Internet portals and get access
to vital information you may need to do your job.
Today, we allow you to access
some basic building blocks of
SharePoint through the Microsoft Graph.
Sites, lists and document libraries,
and list items are all available.
Let's go back over to Graph Explorer and see what we
can find that would be useful to us.
Everything in SharePoint lives in a site somewhere.
So the first thing I can do
is either get the default site
for my tenant or do a simple search for a site.
If I knew the idea of the site,
I could also access it directly.
Let's do the search scenario.
In this case, we searched for Contoso.
That gave us back a set of
both site collections and sub-sites.
Once I see the one I want,
I can take its ID and we can start
accessing the resources underneath it.
Let's use the first one and see what lists it has.
That's as easy as adding
/lists to the URL after I've added the ID.
One thing I can
see in the sample data that came back is that
these lists are using the document library template.
Document libraries are special
in that they are both lists,
which means I can work with the columns and metadata
that might be applied to the items in them,
and drives because they contain files and folders.
Depending on whether I want to do file
things to the items or SharePoint things,
I might need to think in either of those contexts.
Let's look at this document library as a list first.
Just as I could easily add /lists to get the list,
I can add /items to get
the items in the list I'm looking for.
Luckily, when I'm working with a list item that
represents a file in a document library,
I can turn it into a drive item just by
adding /driveitem to the URL.
Here's the first item as a list item,
and here it is as a drive item.
It's easy for me to go back and forth to do
everything I need with a file in SharePoint.
As we start to look at more advanced scenarios,
we can do things like update the columns on a site,
work with content type information, and much more.
Take a look at the Documentation
as you explore the API to
help find all SharePoint has to offer in Microsoft Graph.
This is just the tip of the iceberg.
Today, we looked at the very basics of
working with OneDrive and SharePoint data
through Microsoft Graph.
As you explore, you'll find
even more depth to what is currently
available and the team is continuing to add
new APIs to allow you to fulfill even more scenarios.
The most important things to remember
are Graph Explorer, Documentation,
and of course, we're listening on User Voice for
suggestions if you find something missing. Happy coding.