0

I have embedded a OneNote notebook into a Microsoft Teams Tab. I am trying to get the Notebook Id using Graphi API

I can get the tab id from channels/{{ChannelId}}/messages/delta end point.

Using tabId, I can get tab details from channels/{{ChannelId}}/tabs/{{tabid}} end point.

Tab details end point gives configuration details that has contentUrl and websiteURL.

{
  "id": "tabId",
  "displayName": "My Contoso Tab - updated",
  "configuration": {
    "entityId": "2DCA2E6C7A10415CAF6B8AB6661B3154",
    "contentUrl": "",
    "websiteUrl": "",
    "removeUrl": ""
  },
  "teamsApp": {
      "id": "0d820ecd-def2-4297-adad-78056cde7c78",
      "externalId": null,
      "displayName": "Contoso",
      "distributionMethod": "store"
  },
  "sortOrderIndex": "20",
  "webUrl": ""
}

How can I get notebook Id or Section Id or Page Id that is embedded into the tab?

Danstan
  • 1,501
  • 1
  • 13
  • 20
Kannan
  • 1
  • 1
  • Actually the tamsApp id posted above refers to the standard OneNote App , so i assume the actual output contains this section: ``` json "teamsApp": { "id": "0d820ecd-def2-4297-adad-78056cde7c78", "externalId": null, "displayName": "OneNote", "distributionMethod": "store" } ```` – Jos Verlinde Sep 20 '21 at 10:29

2 Answers2

1

Formally the OneNote tab explicitly has no public documentation regarding its configuration as per : https://learn.microsoft.com/en-us/graph/teams-configuring-builtin-tabs#onenote-tabs.

You can indeed try to reverse engineer the content or web URLs, and you may very well succeed today. But you need to understand , and accept responsibility and the associated integration testing potential downtime as that URL format can/will change with no notification whatsoever.

If you can accept that risk & responsibility, using the oneNoteWebUrl= QSP from the contentUrl json node seems to be a decent key.


            "configuration": {
                "entityId": "00727f3d-df18-43ac-8cc9-698774312f5e",
                "contentUrl": "https://www.onenote.com/teams/TabContent?notebookSource=Pick&notebookSelfUrl=https%3A%2F%2Fwww.onenote.com%2Fapi%2Fv1.0%2FmyOrganization%2Fgroups%0076777f1c-3e3d-44ad-8206-53ba08a44cec%2Fnotes%2Fnotebooks%007-ce5c7935-0960-41f0-a5ce-e82a6d365f45&oneNoteWebUrl=https%3A%2F%2Fm365x432007.sharepoint.com%2Fsites%2FTaaP%2FSiteAssets%2FTaaP%2520Notebook&notebookName=TaaP%20Notebook&siteUrl=https%3A%2F%2Fm365x432007.sharepoint.com%2Fsites%2FTaaP&createdTeamType=Standard&oneNoteClientUrl=https%3A%2F%2Fm365x432007.sharepoint.com%2Fsites%2FTaaP%2FSiteAssets%2FTaaP%2520Notebook&notebookIsDefault=true&ui={locale}&tenantId={tid}&upn={userPrincipalName}&groupId={groupId}&theme={theme}&entityId={entityId}&subEntityId={subEntityId}&sessionId={sessionId}&ringId={ringId}&teamSiteUrl={teamSiteUrl}&channelType={channelType}&trackingId={appSessionId}&hostClientType={hostClientType}",
                "removeUrl": "https://www.onenote.com/teams/TabRemove?notebookSource=Pick&notebookSelfUrl=https%3A%2F%2Fwww.onenote.com%2Fapi%2Fv1.0%2FmyOrganization%2Fgroups%2F46777f1c-3e3d-44ad-8206-53ba08a44cec%2Fnotes%2Fnotebooks%2F1-ce5c7935-0960-41f0-a5ce-e82a6d365f45&oneNoteWebUrl=https%3A%2F%2Fm365x432007.sharepoint.com%2Fsites%2FTaaP%2FSiteAssets%2FTaaP%2520Notebook&notebookName=TaaP%20Notebook&siteUrl=https%3A%2F%2Fm365x432007.sharepoint.com%2Fsites%2FTaaP&createdTeamType=Standard&oneNoteClientUrl=https%3A%2F%2Fm365x432007.sharepoint.com%2Fsites%2FTaaP%2FSiteAssets%2FTaaP%2520Notebook&notebookIsDefault=true&ui={locale}&tenantId={tid}&upn={userPrincipalName}&groupId={groupId}&theme={theme}&entityId={entityId}&subEntityId={subEntityId}&sessionId={sessionId}&ringId={ringId}&teamSiteUrl={teamSiteUrl}&channelType={channelType}&trackingId={appSessionId}&hostClientType={hostClientType}",
                "websiteUrl": "https://www.onenote.com/teams/TabRedirect?redirectUrl=https%3A%2F%2Fm365x432007.sharepoint.com%2Fsites%2FTaaP%2FSiteAssets%2FTaaP%2520Notebook",

--> `oneNoteWebUrl=https%3A%2F%2Fm365x432007.sharepoint.com%2Fsites%2FTaaP%2FSiteAssets%2FTaaP%2520Notebook' --> urldecode

https://m365x432007.sharepoint.com/sites/TaaP/SiteAssets/TaaP%20Notebook

Jos Verlinde
  • 1,468
  • 12
  • 25
0

The response of channels/{{ChannelId}}/tabs/{{tabid}} will contain details for tab and will not return details for the embedded onenote notebooks and pages. However you can get details for onenote notebooks and pages using https://graph.microsoft.com/v1.0/me/onenote/notebooks You can refer below document for more information https://learn.microsoft.com/en-us/graph/integrate-with-onenote

https://learn.microsoft.com/en-us/graph/api/resources/onenote-api-overview?view=graph-rest-1.0

Thanks