0
votes

The Graph API that exists for programmatically controlling OneNote is a web service that affects some cloud-based representation of the user's OneNote notebooks. As such, to impact the state of my OneNote Windows 10 Desktop application, the Windows 10 app must synchronize with the corresponding cloud-based representation.

OneNote Windows 10 synchronizes very regularly with the cloud representation if one is currently changing content on a local notebook, but synchronization nonetheless happens irregularly and far from realtime (at least w/ respect to the Graph API), especially if a user is waiting or idle.

In order to make any interactive OneNote add-on with the Graph API, I the developer need an alternative. Either syncing with the cloud has to happen constantly, or it must be possible to trigger syncing locally after I've made a sequence of notebook changes using the graph API.

Is there any way to do this? I'll even accept relatively hacky options. If not, I feel like this is a massive limitation of the Graph API service that seriously hampers ability to engage as a 3rd party developer w/ Microsoft products.

2

2 Answers

1
votes

OneDrive does not always immediately delete a file that has been programmatically deleted in the OneDrive folder located on a client PC. This seems to be a synchronization problem. On the web, there are many suggestions to work around this problem but all these solutions recommend to resync OneDrive manually. This is not acceptable in my case because this must be done programmatically from my C++ application.

After a lot of (stupid) research/trials/errors (especially manually changing the OneDrive settings), the only solution I found is quite simple (and stupid) : update my C++ code to :

  1. Delete the file in the OneDrive folder

  2. Check that a dummy file exists in the OneDrive folder; the name of this file is equal to the hostname of the user's machine, so there will be as many dummy file as there are users using my application on their machines. In my case, the dummy file was only a log showing the date of the deletion

  3. If the dummy file exists, read its contents and delete the dummy file.

  4. At that step, the dummy file now does not exist in the OneDrive folder ! Create the dummy file with the previously data read at step 3 and append some other text to it (this newly created file will have a different creation date so OneDrive will see that this required synchronization)

After step 1 is executed, the deletion of the file is not synchronized on others machines. After steps 2-4 are executed, the deletion of the file is successfully and immediately synchronized !

In order to verify that the problem is really a OneDrive synchronization problem, I setup a folder shared among machines. In this case, after step 1, the deletion is immediately synchronized and step 2 is not required for the deletion to be synchronized.

I test my solution on Windows and Mac and it works !

0
votes

I've found that while OneNote for Windows 10 doesn't have constant cloud synchronization, OneNote 2016 does: when I make a change to a notebook with the Graph API, the update is sent to my notebook on OneNote 2016 very quick, even while idle. Strangely, the Graph API seems better designed for the older program than the newer one! I'll just stick with that one and hope those behind the new OneNote eventually achieve an application that's on par with what they're sunsetting.