Graph API create a driveItem with package property set - microsoft-graph-api

Using Microsoft graph API there are ways to create folders (as described here) or files (described here) driveItems.
However the driveItem also allows to have a package property, which makes it something different (currently only a package of {'type': 'oneNote'} can exist); it can easily be read but I can’t find a way to create such a package.
Using the OneNote graph API is not an option, since we work with tenant ID and it does not allow to create OneNote notebooks.
Am I missing something or is it really impossible (getting familiar with graph API I suspect the second)?

It is not possible to set a package property because it is read-only.
Resources:
driveItem properties

Related

Is it possible to create, update, and delete events on a public folder calendar through the MS Graph API?

The question pretty much sums it up. I'd like to create/delete/update events in a calendar that's accessed by several people on a public folder using the Graph API, but haven't been able to find much about how to do it, at least not in the official documentation.
I found this post from 2018 saying "Public Folders aren't yet accessible via the Graph API", but I don't know if that still applies in 2021.
As for SO, the only other question I could find which seems related to this was How to read Public calendar with MS Graph API , but it unfortunately doesn't contain much information either.
In case Graph doesn't support this, would it be possible to do it in some other way (e.g. with some other API)? Ideally something that can be used from Java. Thanks in advance!
No you can't access Public Folders (or Online Archives) using the Microsoft Graph and given the legacy status of Public Folders I don't think they have plans to change this. You can use EWS to access them (make sure you include routing headers through https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/public-folder-access-with-ews-in-exchange).
Moving your Public Folder Calendars to a Office365 Unified Groups is generally a better idea you get improved functionality and you can use the Graph API and other Group workloads for future needs etc.

Microsoft Graph | combining both search and filtering on one API call

I am working on integrating MS Graph inside my application and one scenario I have to list files from OneDrive with search, filtering and sorting functionality but the API listed on the official docs doesn't work
Currently I am calling 3 APIs to make search, filtering and sorting work together.
Note: when I tried the API listed on the official docs I got this error
I think that Microsoft Graph API doesn't support filtering on files or folder directly.
Try to use the Onedrive Rest Api like this
GET: drive/root/children?filter=folder+ne+null

Microsoft Graph support for creating document sets and managed metadata term columns

I recently started testing the Microsoft Graph APIs, I've been able to successfully upload and delete documents in SharePoint Online document libraries through it.
I have not seen anything documentation around this and would guess it's not supported but wanted to confirm, in case I missed it - Does the Microsoft Graph API support creating document sets and/or updating managed metadata columns?
Based on my test, the managed metadata should have not been supported. Although no official docs states this.
If you cannot get the information by the expand=fields too, I'd suggest you to submit a feature request first: https://officespdev.uservoice.com/

Graph API - Get recent files from a particular site collection

I'm trying to fetch recent files from SharePoint Online using Microsoft Graph.
The API I'm using is :
https://graph.microsoft.com/v1.0/me/drive/recent
But the results include files from all site collection. I need to restrict the results to only a single site collection.
After some research, I found that there is no direct API to restrict the site collection.
I also tried using adding filter like :
$filter=sharepointIds/siteId eq 'site-id'
but it was also not working. It gave a `501 (Not implemented) error.
Update:
I found another API from Graph which is
https://graph.microsoft.com/beta/me/insights/used
which is inside insights(beta) named "items viewed and modified by me"
But it again returns data across tenant and I need to restrict it to a single site collection. I guess filter conditions are not yet implemented for this API in Graph.
Is there any method to get recent files from a particular site collection? Any help is appreciated.
One correction, /me/drive/recent isn't pulling from all site collections, it's pulling from the current user's OneDrive. This includes recent files held within their drive and any recent changes to files that have been shared with them.
As for finding Recent Files from a SharePoint Document Library, you need to make this request within the context of the drive you want to pull from. For example:
https://graph.microsoft.com/v1.0/sites/root/drives/{documentLibraryId}/recent

How do I make OneDrive put fail, when the item already exists?

Using the Microsoft Graph Explorer, I can use http PUT to create a OneDrive item.
For example, the uri below creates a testfile.txt at my root:
https://graph.microsoft.com/v1.0/me/drive/root:/testfile.txt:/content
Now, I would like the PUT to fail, if the file already exists, and the general documentation on OneDrive items, https://dev.onedrive.com/items/upload_put.htm#optional-query-string-parameters, states how to specify conflict behavior - if I read it correctly, like:
https://graph.microsoft.com/v1.0/me/drive/root:/testfile.txt:/content?#microsoft.graph.conflictBehavior=fail
However, the PUT still successfully overwrites the existing 'testfile.txt'.
Can anyone help me write a PUT query so that it fails in case the item already exists?
Is that even supported by OneDrive?
Do I need to go to the beta version of Microsoft Graph?
Per the documentation this should be specified within request body, not as a query parameter:
{
"item": {
"#microsoft.graph.conflictBehavior": "fail"
}
}
This is also only supported in the Resumable Upload" scenario as the request body for a direct upload is the file itself. In general, the guidance is to always use resumable uploads where possible. Direct uploads are limited to files less than 4MB which makes it unsuitable for most scenarios.
It is also worth noting that the documentation you referenced is for the standalone OneDrive API. While this is very similar to Graph's implementation, they are not entirely interchangeable. The Microsoft Graph documentation is the only authoritative source for Graph information.

Resources