Onenote does not return pages - onenote

This is similar question as OneNote pages API doesn't return pages in section-groups.
I'm using the Get sections and get Section pages with Sections expanded to get names for all pages in a notebook. However using the same requests all the time, the sections in section groups sometimes disappears, and wont reappear before recreating the group.
Is this a bug that one can somehow work around, or is there a better way of polling all the page names from a specific notebook? The pages need to be in order.

If you are trying to get all the page names for a Notebook, a work-around exists by using an OData nested filter. The idea is to query for all pages, $expand the parentNotebook, and then $filter on the id of the parentNotebook. Here is an example URL.
GET ~/pages?$expand=parentNotebook&$filter=parentNotebook/id%20eq%20'{$notebook_id_here}'
Here is another SO question where someone employs a similar pattern: Best way to use One Note API to GET specific pages in specific section in specific notebook?
Update:
You can control the order of the returned pages by using OData's $orderby and specifying properties that exist on the entities in the returned entity set (in this case, the entity is pages). From dev.onenote.com: "The default [order] is lastModifiedTime desc (most recently modified page first)."
Under https://dev.onenote.com/docs#/reference/get-pages there is a section, "Page properties", that shows all the properties returned by this call. Since we are getting all the pages available to a user that exist in a notebook, the only property we can use is unfortunately createdTime.
The query param to add looks like $orderby=createdTime
In full:
GET ~/pages?$expand=parentNotebook&$filter=parentNotebook/id%20eq%20'{$notebook_id_here}&$orderby=createdTime
I just tested this using Fiddler against my own pages so I think it should work. The nice thing is that it is a single request.
GET https://www.onenote.com/api/v1.0/me/notes/pages?$expand=parentNotebook&$filter=parentNotebook/id%20eq%20'{$YOUR_NOTEBOOK_ID_HERE}'&$orderby=createdTime

Related

Inconsistency in MS Graph API behaviour for onenote

When a section renamed get sections API doesn't reflect the updated name whereas get page api shows updated parent section name. This seems to be bug/ data inconsistency in ON API.
On change of anything at page level updates the lastModifiedDateTime for a section but nothing gets changed at notebook level. This again seems to be like some data inconsitency issue.
Can somebody clear this confusion.
(Note - All above can be tested using MS Graph API Explorer
)
These are two separate topics:
Section renaming
This is a known limitation/bug in OneNote - if you rename a section in OneNote Online (in your browser), then the API GET ~/notebooks/id/sections or GET ~/sections will give you the "old" name. This is because OneNote Online doesn't actually rename a file, it only marks the file as "to be renamed" - if you were to look at the file itself in OneDrive/SharePoint it would still have the old name.
Once the OneNote Native Client sees the section (for example OneNote for Windows) sees the section that has been marked as "to be renamed", it actually renames the file.
The OneNote API GET ~/sections/id/pages actually looks at the section binaries and is able to tell whether the section is renamed or not, which is why that name can be trusted as the "most up to date" one.
I have communicated this feedback to our team and we are exploring alternatives - I encourage you to start an item in uservoice so we can better understand impact.
https://onenote.uservoice.com/forums/245490-onenote-developer-apis
LastModifiedTime (LMT) on notebook/section clarifications:
The LMT of a section is equal to max(LMT of pages under it).
The LMT of a section group however is not max (LMT of sections and section groups under it). A section group is a folder and its LMT should behave like that of a folder in a traditional file system (reflects time of last add/delete of a file/folder directly under it).
However, there is nothing stopping you from using $expand and calculating the LMT (as you understand it) yourself based on the entities below the notebook/section group.
https://blogs.msdn.microsoft.com/onenotedev/2014/12/16/beta-get-onenote-entities-in-one-roundtrip-using-expand/

Scan an area of a web page's source code for changes while reporting it?

this is one heck of a confusing question to ask so here it goes. Firstly, I'm not asking you to write me any code I just need help going in the right direction for what I'm trying to achieve here. Basically the task is this, I want to scan a select area of a web page's source code for changes and if something does change, I want to report it somewhere (like a console or something). However, I do not want just a notification of change, I also want what the change is/was. I've been looking into things like jsoup but I am still struggling to even find out what this is called.
Any pointers would be insanely appreciated. Thanks, Optimistic.
Here are some steps assuming this is from a node.js project:
Get the URL for the specific script file you're looking for a change in.
Using the request() module, fetch that URL.
Break the data up into lines (probably using .split()).
Find the specific line you are looking for either by counting line numbers of by searching for some representative text in that line.
Using some sort of search in that line (perhaps a regex), find the current value of the exact item in that line you are looking for.
Save the current value.
Then, at some future time, repeat this whole process and compare what you find to the previous value.
If this is being done from a browser instead of node.js, then use an Ajax call to retrieve the file. If the file is on another domain from your web page and that domain does not permit cross-origin requests, then you cannot solve this problem in an automated fashion from a browser in your own web page.
Here is how I would do it with Jsoup:
Document doc = Jsoup.connect(url).get();
String scriptCssQuery = "script"; // Tune this CSS query to find THE script you need.
Element script = doc.select(scriptCssQuery).first();
if (script != null) {
String scriptLines = script.html();
// Store the changing line somewhere and compare it to its previous value...
}

Extract HTML Tables from Multiple webpages Using R

Hi I have done thorough research and have come to this extent. All I am trying to do is extract HTML table spanning many webpages.
I have to query the website sec.gov's database and the table then returns appropriate number of results (the size and number of pages vary with every query). For example:
Link: http://www.sec.gov/cgi-bin/srch-edgar
Inputs to be given:
Enter a Search string box: form-type=(8-k) AND filing-date=20140523
Start: 2014
End: 2014
How can I do this totally in R without even opening the browser?
I am sharing what all I have done
I tried many packages and the closest I came to was package RCurl. But in getURL function I opened the browser, ran the query in browser and pasted it in getURL. It returned a very long character, which has the URLs that can be looped and produce the output I want. All this information is in the "center" tag of output.
Now I do not know how to get those URLs out from the middle of the character.
Also, this is not what I wanted. I wanted to run a web query directly from R and get the varied HTML table outputs directly into R. is this possible at all?
Thanks
Meena
Yes, it is possible. You will want to use a combination of the RCurl and XML packages. You will need to programmatically generate the query parameters in the URL (based on the HTML form) and then use getURL() or getURLContent(). Sometimes, the server will expect an HTTP POST, so there is postForm().
To parse the result, look up the XPath language, which the XML package supports with getNodeSet(). I think there is also a function in the XML package for parsing an HTML table into a data.frame.
You might want to invest in this book.

Variable in MediaWiki for the current user

In MediaWiki, you can use a variable ("Magic Word") such as
{{PAGENAME}}
or
{{REVISIONDAY}}
to get specific information related to the current page being viewed. Is there a similar variable (or perhaps a different way) to get the current user who is logged in to the wiki, i.e. something like
{{USERNAME}}
context: Trying to use the #ask query in Semantic MediaWiki to narrow the list of resulting pages to show those only the user has created or edited:
{{#ask: [[Case Reflection:+]] [[Contributing User::{{USERNAME}}]]
| format=template
| template=Case Reflection Form Summary
| link=all
| sort=Last Edited
| order=DESC
| default=You have no case reflections related to this Case Study.}}
There are a bunch of extensions for that such as GetUserName, MyVariables, UserInfo. The whole concept of showing usernames is incompatible with page caching though (you need to parse the page again every time someone looks at it) so generally not a good idea.
I was just searching for the same thing, and looking to see if I could do it without extensions. It looks like there's a default feature that allows this, as long as you want it as part of writing a static version to a page, not to say "Hello, Username!" (That last case is why they have not implemented it as a standard variable, because it causes caching problems.)
Wikimedia feature request T14733 resolves with:
{{subst:REVISIONUSER}}
{{REVISIONUSER}} will dynamically show the last editor, which is usually not what you want. But if you want, for example, to make a template that includes the user's handle as part of some inserted text, this should do the job. I think in your example above,
[[Contributing User::{{subst:REVISIONUSER}}]]
(I'm not sure if Semantic Mediawiki will make you escape out the substitutions, but if it does, further instructions are at Manual:Substitution, Multilevel substitution section.)

Drupal 7 - Adding Nodes Through phpmyadmin is not Working Correctly

I have received a Microsoft Access database file and was tasked to convert the contents into something readable by mySQL standards for a Drupal 7 website database. I managed to upload them into the "node" table successfully, with the correct content type classification, unique primary keys and node IDs, etc. Or so I thought.
When I checked the Drupal site, I checked the list of content type X, and all of the new stuff was there. However, when I tried to click them, instead of opening the new page like I expected it to, I received a "page not found" message, instead. I tried looking for the new content manually via "Find Content", but none of it was showing up. I checked entity reference lists that referenced content type X, but they were not showing up on those lists, either.
I checked which fields were required for content type X, and I found that "location category" and "address" were required fields. So to test, I only added 1 entry to each of those tables (both field_data and field_revision versions of the required field), representing the 1st of the many I tried to transfer over. Still nothing. I have no idea what I could be doing wrong. Can anyone offer some insight?
Adding content to Drupal through the database is absolutely the wrong way to go about creating content. I suggest you try any of the following methods:
Create the nodes programmatically using Drupal's API functions:
http://fooninja.net/2011/04/13/guide-to-programmatic-node-creation-in-drupal-7/
Upload data through a CSV file using the Feeds module:
http://drupal.org/project/feeds/