Onenote notebook, sections and page IDs permanent? - onenote

I'm using the API here: https://learn.microsoft.com/en-us/graph/onenote-get-content#resource-paths-for-get-requests to get and write information to pages.
I was wondering if anybody knows whether the IDs retrieved through the API changes. I found this Converting between OneNote Ids for internal vs HTML links?, which says that the runtime IDs change. But I tried a few calls and doesn't seem to change, so I'm very confused.
I'm wondering if there is a key like reference for Onenote objects, as like a google sheet where each sheet has a unique key and that never changes. I'm looking for an anchor like that.

Omer's answer in the thread linked is correct.

Related

Is there a way to list who viewed a file (and when)?

I'm searching for a little while and I can't find what I'm looking for, so it may be a good idea to ask it here.
Is there a way to obtain, by API, for a specific file, the name of the last user (and timestamp) who accessed a file?
Goal: to write to script to know who access what on my drive.
Unfortunately, what you want cannot be achieved. The Drive Activity API is used only for retrieving the activity on the specified file. You can gather the users who have view access but not the ones who have actually viewed the file.
The action object from the Drive Activity API is represented by the action detail. For a document at the moment, the action details are the following: create, edit, move, rename, delete, restore, permissionChange, comment, dlpChange, reference, settingsChange. Therefore, taking these into account as well, you cannot see who viewed a file.
Since the option of seeing the actual viewers of a file is still a relatively new feature in the UI, the option for the API does not yet exist.
What you can do instead is to file a feature request on Issue Tracker by accessing this link here.
Reference
Drive Activity API
You can use the Drive Activity API.

Retrieving comments in the most recent revision of Google Doc

I'm pretty new to Google Apps Script and the API, so please bear with me!
As part of a project I'm working on, I would like to retrieve all the comments that are present in the current revision of a file, hopefully using either Google Apps Script or the Google API.
The reason I want this is that the documents I'm working with have had many collaborators and many different revisions, and some of the people who were supposed to be 'resolving' comments didn't realise that even though deleting the text a comment is anchored to removes the comment from the user interface, this comment still counts as "open". i.e., these comments still appear in the comments thread, it just looks like they link to an earlier revision of the file.
Now, I want to retrieve all the comments present in the most recent versions of these files and -- say -- export them to a Google Sheet. However, if I choose all "open" comments, I get many, many more comments than I want, for the reason I stated above.
One possible way I was considering is to decipher the comment's anchor id "kix.xxxxxxxxxxxx", hoping that it would at least give me information on the revision history, but I see no documentation on this, and I'm not even sure it's possible since this is related to Google proprietary editor Kix.
I've read these articles that don't give me much hope:
How to match comments on an image using kix anchor (or not) in Google
Docs
Anchor documentation does not exist?
Creating anchored comments programmatically in Google Docs
However, If I download the Google Doc to a .docx, then I get only the comments that are present in the most latest revision, and this is what gave me some hope that maybe it would be possible to extract them using GAS.
I suppose if all else fails I could download all the documents and then try to get some sort of macro on Microsoft Word to extract the comments, but I decided to ask here before I resorted to that! If anyone could suggest any ideas, I'd be grateful!

How can I access Box.com Comments using API

I am trying to using Box API to get comments that have been made on the files and folders.
I have tried looking at the box content api but could not find anything useful. Am I missing something here?
AS is usually the case it turns out I was not digging real deeply into the documentation.
Here is the link to the documentation for accessing comments in the box.com api.
https://developers.box.com/docs/#comments
The link explains it really well. I cant really think of copying and pasting it here since I wont be adding anything. The key concept in box.com api is the authentication and after that one can simply pass parameters for file_id and then post and go to /comments url and get the response. Then comes the sifting of comments which can also be done using the api.

files.list() reproducibly returns incomplete list in "drive.files" scope

Our application needs a full list of the user's files and folders. We use files.list() via the Javascript library (essentially the same code as shown in the official API reference as an example).
We use the "drive.files" scope.
Examining the response to the list, we find that some files are always missing. I did various tests to understand the problem:
The files clearly exist. They show up in the Google Drive Webapp and, if I explicitly request them via ID, I can get them via the API without problems.
It's reproducible, always the same files are missing.
It is not transient. I tried a day after and still the same files are missing. I know of a few strange effects in the API that go away after some time but not this one.
It is not a one time thing (e.g. some weird things went wrong during upload). If I repeat with a completely different Google Account again files are missing. Of a small set of 147 uploaded files in one test 4 are missed by the files.list call, in another test with the same 147 files on another account 23 files are missing.
It only occurs when I use the drive.files scope. If I relax the scope to drive all files are returned. If look at "Details" in the Google Drive Webapp also the missing files are shown as created by our Application. So it does not seem that they lost their origin somehow.
It also occurs when I specify a search query. If I call files.list with a search term "q: modifiedDate > '2012-06-04T12:00:00'" which also should return all files, the same files are missing.
I re-implemented the same thing as pure REST call to the API to rule out that it is an issue with the Javascript library. The error remains.
Update: I could track it down to an issue with the paging and the maxResults parameter. If I use different values the API returns different number of items:
With maxResults=100 I get 100+100+7=207.
With maxResults=99 I get 99+99+28=226.
With maxResults=101 I get 101+101+0=202.
The last result is interesting which gave me a nextLink indicating there are more results but the items array in the last response was actually empty. This alone might indicate a bug.
Still, this only occurs in drive.file scope, the counts are consistent in the full drive scope.
I'd be glad to hear ideas for a workaround. I'm aware of other ways to keep track of the users files, e.g. using the changes feed. I'm using that already but for a specific part in our application I simply need a reliable and complete list of all our application's items in a user's account.
One more note: We had other issues with the "drive.files" scope before (see Listing files with search query returns out-of-scope results (drive.files.list call, using drive.files scope)). This turned out to be an easy fix. Perhaps this issue is related.
Are there any difference in the files belonging to "shared to me" and own files/folders, was the issue for me ?
The way it is presented in Google Drive was not the same result I got when searching without the correct flags.
I found out when I did this file list with all the folders, that I did have to include from where the search scope of files should be.
- Include deleted files
- Include shared to me files

Calling a Google Drive SDK from Google App Script application

i have been going around in circles here and have totally confused myself. I need some help.
I am (trying to) writing an application for a client that in concept is simple. he want a google write document with a button. the google drive account has several folders, each shared with several people. when he drops a new file in one of the folders, he wants to be able to open this write file, this file is the template for his email. he clicks the button, the system calls the changes service in the Google Drive SDK https://developers.google.com/drive/manage-changes, gets the list of files that have been added since the last time it was checked, then pull the list of people that the file has been shared with, and use the write file as a template to send that list of people an email saying their file is ready.
SO, easy enough, right?
I started by looking at the built in functions in the Google App Script API. I found this method, https://developers.google.com/apps-script/class_docslist#find in the DocsList class. problem is the description for the query simply says "the query string". So at first i tried the Drive SDK query parameters, which are
var files = DocsList.find("modifiedDate > 2012-12-20T12:00:00-08:00.");
it didn't work. that leads me to believe it is a simple full text search on the content. Thats not good enough.
That lead me into trying to call a Drive SDK method from within an App Script application. Great, we need an OLap 2 authentication. easy enough. found the objects in the script reference and hit my wall.
Client ID and Client Secret.
you see, when i create what this really is, a service account, the olap control in apps script doesn't know how to handle the encrypted json and pass it back and forth. Then when i tried to create and use an installed applications key, i get authentication errors because the controls again, don't know what to do with the workflow. and finally, when i try to create a web app key, i can't because i don't have the site host name or redirect URI. And i can't use the application key ability because since im working with files OLap 2 is required.
i used the anonymous olap for a while, but hit the limit of anonymous calls per day in the effort of trying to figure out the code a bit, thats not going to work because the guy is going to be pushing this button constantly thru the day.
i have been pounding my head on the desk over this for 5 hours now. i need some help here, can anyone give me a direction to go?
PS, yes, i know i can use the database controls and load the entire list of files into memory and compare it to the list of files in the database. problem being, we are talking tens of thousands of files. bad idea.
I wouldn't use DocsList anymore - DriveApp is supposed to be a more reliable replacement. Some of the commands have changed, so instead of find, use searchFiles. This should work more effectively (they even use a query like yours as an example).