Difference between notebook id by OfficeJS and OneNote API

走远了吗. 提交于 2019-12-02 06:40:42

问题


I'm trying to build task-pane add-in for OneNote ClassNotebook.

I want to know whether current user is teacher or student.

To achieve this, my plan was:
1. Get ID of activeNotebook from officeJS
2. Get class notebooks with ID from 1 from OneNote API
3. Use students and teachers from 2 to check if current user is student or teacher

But the id from 2 is something weird form like this -{3b9c6337-cd8c-5c1c-a87b-1a9515237c48}{1}

How can I fetch notebook with that ID?

Code:

let notebook = ctx.application.getActiveNotebook();
notebook.load('id,name,clientUrl');
return ctx.sync().then(() => {
  fetch({
    url: `https://www.onenote.com/api/v1.0/me/notes/classNotebooks/${notebook.id}?expand=students,teachers`
  });
});

回答1:


EDIT: I'm happy to say this is now available, use GetRestApiID for this.

https://github.com/OfficeDev/office-js-docs/blob/master/reference/onenote/page.md#getRestApiId


At this moment, the OneNote REST API and OneNote add-ins have imcompatible id's. There is a uservoice entry for this: https://onenote.uservoice.com/forums/245490-onenote-developer-apis/suggestions/17010982-add-onenote-add-ins-to-onenote-api-compatible-ids

For now, you'll have to rely in something like the URLs or the names.




回答2:


The Id between REST API and JavaScript API are not compatible. What is compatible is ClientUrl.

In JavaScript API, there is notebook.ClientUrl In Rest API, it has oneNoteClientUrl.



来源:https://stackoverflow.com/questions/40491066/difference-between-notebook-id-by-officejs-and-onenote-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!