How can I get folder's items in original sort order? I want to get items in the same order as OneDrive folder has online. I have many folders with custom sort arrangements, but I’m always getting items sorted by name only.
var res = Client
.Drive
.Items[FolderId]
.Request()
.Expand("children($expand=thumbnails)")
.GetAsync(); // where FolderId is variable
res.Children always contains items sorted by Name only, no matter what res.Folder.View.SortBy value is.
I'm using Microsoft Graph Client Library.
Do you use OneDrive or OneDrive for Business?
In OneDrive for Business, Graph only supports sorting by name or url. For personal OneDrive, only name, size, and lastModifiedDateTime.
What parameter do you use for sorting when you access your OneDrive with a browser? Is it sorted by date? If so, I'd suggest to add your vote on the Office User Voice
Related
I am looking for the best way to check if a file has been checked out by a user using the OneDrive SDK. This is just a layer on the Graph API. I wish to prevent downloads in my application if the file is checked out.
I am getting the contents of a folder using this
var results = await graphClient.Drives[driveId].Items[folderId].Children.Request().GetAsync();
However there does not appear to be any properties in this response around if the item is checked out?
From my testing I can attempt to checkout the file anyway and handle an exception is returned if the file is already checked out, but this is not something I would want to do for multiple items for obvious performance reasons.
await graphClient.Drives[driveId].Items[documentId].Checkout().Request().PostAsync();
Is anyone aware of a more efficient way to determine if files are checked out?
You need to read publication property of publicationFacet type. It provides details on the published status of a driveItem resource.
publicationFacet type has property level which describes the state of publication for this document. Either published or checkout.
publication property is not returned by default and must be specified in Select method.
var results = await graphClient.Drives[driveId].Items[folderId].Children
.Request()
.Select("id,...,publication")
.GetAsync();
Documentation
publicationFacet
We want to query a SharePoint tenant periodically for any new sites/subsites created since the last time the query was run (e.g. once every 5 minutes).
We are open to running graph queries at the SharePoint tenant level or the SharePoint site collection level.
This tenant has >50,000 sites + subsites in it. Enumerating them all takes too long. So we are hoping to create a graph query that can identify only sites with a creation date within a narrow range so we can make this process faster.
Cany anyone share more information on how to achieve such a query across the tenant, or site collection, for site creation date? Thanks in advance.
The fastest way to list all tenant's sites (large amount) is querying a hidden system list. It requires to have the right permissions to read listitems.
First, list all SP lists via the query: https://graph.microsoft.com/v1.0/sites/<yourtenant>-admin.sharepoint.com/Lists/?select=id,name
Next, via MS graph, you can query and filter the listitems in the list with the displayname DO_NOT_DELETE_SPLIST_TENANTADMIN_ALL_SITES_AGGREGATED_SITECOLLECTIONS as all sites' references are there. You can use the integrated pagination URL in #odata.nextLink property. Read : https://learn.microsoft.com/en-us/graph/paging
Also, another option, via a search query it is possible too :
https://graph.microsoft.com/v1.0/sites?search='<site_name_or_alias>'&filter=createdDateTime ge '2020-10-26T00:00:00Z'.
However, beware of the fact that just a few properties are supported for filtering if you use the search.
I'm attempting to use MS Graph to parse the contents of excel files and sync the data with other business-line applications. The issue I'm running into is actually getting at the data in excel.
I'm using a ClientCredentialProvider authenticating to an Azure AD App Registration which has FullControl and Read.All permissions in my tenant to create my GraphServiceClient, and can successfully query the Site via ID, and even see the document library I'm trying to access, but the Items comes up empty. See below
var result = _graphService.Client
.Sites["my-site-id"] // This works
.Drives["site-drive-id"] // This works to find the document library
//.Lists["list-id-corresponding-to-folder"] // This also works to find that folder
.Items // ****This is null****
.Request()
.GetAsync()
.Result;
I tried using the Lists property (as noted above) because as I understand it document libraries in SharePoint are really just lists, but again the Items enumeration yields no results.
I can't find documentation on Microsoft's site on this use case, and I notice using the MS Graph Explorer that the returned object doesn't have an "items" field (or many properties in the Microsoft.Graph.Site class), but I would think there is some way to get this field populated since it's implemented in the Microsoft.Graph namespace. Not sure if I'm missing some permissions step or what, but if I can access the site with FullControl I should be able to access all its contents...
I can't use Client.Me (personal drive) as a source location because 1) the application doesn't run under my permissions and 2) there is a need to read multiple files; the idea would be just provide the needed site/drive/item ID's and get the documents.
Is there some other way I should be going about this?
#broccoli_rob,
MS Graph has not exposed the functionality of enumerating all items in a drive. Instead, you can only list children or get item by id.
We suggest you use /drive/root:/{item-path} to get items in a folder. And you can vaild the endpoint in Graph explorer:
BR
I'm trying to get all the Deleted Items or Trash folders for all the mail accounts in Outlook. I'm using Outlook Interop in C#, but I can only find the way to get the deleted items folder in the default mail account on MSDN: Application.Session.GetDefaultFolder(OlDefaultFolders.olFolderDeletedItems).
Does anybody know if there is a way that I can get the deleted items folder in every email accounts in Outlook?
Loop through the Namespace.Stores collection and call Store.GetDefaultFolder(olFolderDeletedItems) instead of Namespace.GetDefaultFolder.
In response to the "should work on Outlook 2007" requirement you added in your response to Dmitry's answer, I'd suggest the following approach:
Use a PropertyAccessor to acquire the PR_IPM_WASTEBASKET_ENTRYID ("http://schemas.microsoft.com/mapi/proptag/0x35E30102") of the store
Use PropertyAccessor.BinaryToString to convert it to an EntryID you can use in the COM/interop layer
Use NameSpace.GetItemFromID to access the deleted items folder folder, given it's EntryID and the EntryID of the store.
The only question I could find on SO was from 3 years ago and is not working for me.
Context: I am creating a C# webservice that needs to retrieve all users from a company's directory. This particular method needs the name and email of each user so it can populate a few lists. I am using Microsoft Exchange Web Services Managed API 2.0 downloaded from: here.
You probably want to use the FindItems method with a paged search (so that you can limit the number of contacts returned in each message).
This topic has info about getting items (contacts are just items): http://msdn.microsoft.com/en-us/library/office/dn535506(v=exchg.150).aspx#bk_getewsma. You'll want to create a property set to retrieve the name and email address from the ContactSchema.
And this topic has info about doing a paged search: http://msdn.microsoft.com/en-us/library/office/dn592093(v=exchg.150).aspx.