How to get OneNote Notebook/Section/Page Id from Teams Tab - microsoft-graph-api

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?

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

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

Related

How to tell the difference between a SP Online drive and a Teams channel-drive?

Using the MSFT Graph API, is there a way to differentiate Drives (which are documentLibraries) that are used for Team-Channels versus those that are "simply" documentLibraries created WRT a more generic, SharePoint Online Site?
Retrieving a user's /v1.0/sites?search=* returns a union of SPO Sites the user is a member of and Teams the user is a member of. (Yes, Teams are SPO sites or libraries within a site natively.)
I need to differentiate either the Sites by whether or not they're a Team-Site (because I can then filter Drives returned), or specifically all the Drives returned to differentiate whether the Drive is a Channel-Drive or simply a plain-old documentLibrary that is part of a Site.
Retrieving Sites from Graph shows no apparent properties that indicate what "type" of Site it is, and neither do the Drives queried from each Site (/v1.0/sites/SITE-ID/drives).
Thanks.
One of the way can be check the owner of the drive associated with the site
GET https://graph.microsoft.com/v1.0/sites/{siteId}?$expand=drive
That endpoint will return site info including drive info
{
"description": "...",
"id": "xxx",
...
"drive": {
"description": "",
"id": "xxx",
"driveType": "documentLibrary",
...
"owner": {
"group": {
"email": "xxx",
"id": "42857780-3ab6-412d-a9b8-5e6adc73aabb",
"displayName": "xxx"
}
},
"quota": {}
}
If the owner has property group then you can use group id in the following endpoint
GET https://graph.microsoft.com/v1.0/groups/{groupId}?$select=id,resourceProvisioningOptions
Response:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#groups(id,resourceProvisioningOptions)/$entity",
"id": "xxx",
"resourceProvisioningOptions": [
"Team"
]
}
select resourceProvisioningOptions which specifies the group resources that are provisioned as part of Microsoft 365 group creation, that are not normally part of default group creation. If one of the value is Team then the drive is used for teams.
Resources:
group

Can't add Teams bot to a channel

This was originally a support ticket to Microsoft. However they told they don't do dev support without paying for it. They directed me to Stack Overflow, so here goes nothing.
I'm developing a Bot for Microsoft Teams. I have registered my bot with Azure Active Directory, & Bot Framework. I have uploaded my app to Team, without any errors. My bot is currently able to send direct messages to Teams users. However, when I try to add my bot to a Teams channel, I get unhelpful errors.
I click the dropdown under my app in the Apps tab:
I click "Add to a Team", then select a channel:
After clicking the button "Set up a bot", I get the following error message:
I have checked & rechecked my webApplicationInfo.id & webApplicationInfo.applicationPermissions numerous times, and I'm at a loss for what could be amiss. I don't see how either of these fields could be wrong given, I can authenticate with both the Microsoft Graph & Bot Framework apis using these values. Here's a slightly redacted version of my Teams app manifest:
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.8/MicrosoftTeams.schema.json",
"manifestVersion": "1.8",
"version": "1.0.15",
"id": "<TEAMS_APP_ID>",
"packageName": "ambition",
"developer": {
"name": "Ambition",
"websiteUrl": "https://ambition.com",
"privacyUrl": "https://ambition.com/privacy",
"termsOfUseUrl": "https://ambition.com/pages/terms"
},
"icons": {
"color": "logo_opaque_192x192.png",
"outline": "logo_transparent_32x32.png"
},
"name": {
"short": "Ambition",
"full": ""
},
"description": {
"short": "Motivate & Recognize",
"full": "Ask Marketing"
},
"accentColor": "#FFFFFF",
"permissions": [
"identity",
"messageTeamMembers"
],
"validDomains": [
"ambition.com"
],
"bots": [
{
"botId": "<AZURE_ACTIVE_DIRECTORY_CLIENT_ID>",
"scopes": [
"team",
"personal",
"groupchat"
],
"isNotificationOnly": true
}
],
"webApplicationInfo": {
"id": "<AZURE_ACTIVE_DIRECTORY_CLIENT_ID>",
"resource": "https://ambition.com",
"applicationPermissions": [
"Channel.ReadBasic.All",
"ChannelMessage.Send",
"Group.Read.All",
"Notifications.ReadWrite.CreatedByApp",
"Team.ReadBasic.All",
"User.Read",
"User.ReadBasic.All"
]
}
}
The webApplicationInfo section is really only for two things: Tab SSO, and Resource-Specific Consent. Are you trying to implement either one of those? If not, removing it is definitely the best option, as you've noted in your answer.
In addition, I see that the resource values you've put in there are Microsoft Graph Scopes, whereas the applicationPermissions section is expecting a different list of options (they look kind of similar, but their not the same thing). See here for more: https://learn.microsoft.com/en-gb/microsoftteams/platform/graph-api/rsc/resource-specific-consent#resource-specific-permissions
Don't really know why this works, but I compared my app manifest to the one generated by going through this tutorial: https://learn.microsoft.com/en-us/microsoftteams/platform/build-your-first-app/build-bot.
Removing the webApplicationInfo property from my manifest fixed the issue. Don't really understand why it was causing a problem in the first place.
https://learn.microsoft.com/en-us/microsoftteams/platform/resources/schema/manifest-schema#webapplicationinfo

Using filter on /me/joinedTeams not working

I'm implementing a search for a user's joined Teams unsing Microsoft Graph. The idea is to make a call to /beta/me/joinedTeams and use a ?$filter=startswith(description,'searchterm') filter.
So for example when I try the request https://graph.microsoft.com/beta/me/joinedTeams?$filter=startswith(description,'Business') in the Microsoft Graph Explorer it ignores the filter and I get these results:
{
"#odata.context": "https://graph.microsoft.com/beta/$metadata#groups",
"value": [
{
"id": "02bd9fd6-8f93-4758-87c3-1fb73740a315",
"displayName": "HR Taskforce",
"description": "Welcome to the HR Taskforce team.",
"isArchived": false
},
{
"id": "13be6971-79db-4f33-9d41-b25589ca25af",
"displayName": "Business Development",
"description": "Welcome to the BizDev team.",
"isArchived": false
},
{
"id": "8090c93e-ba7c-433e-9f39-08c7ba07c0b3",
"displayName": "X1050 Launch Team",
"description": "Welcome to the team that we've assembled to launch our product.",
"isArchived": false
}
]
}
Am I doing something wrong with my request?
Your request is right, but the joinedTeams does not support filtering or ordering results. So although we pass the filter/orderby parameter, when Microsoft Graph sees a query parameter it doesn't expect, it simply ignores the unknown filter/orderby parameter and returns an unfiltered/default-sorted result.
I have tried the api with odata query parameters for trial O365 account and real account.
https://developer.microsoft.com/en-us/graph/docs/concepts/query_parameters
Not all parameters are supported across all Microsoft Graph APIs, and
support might differ significantly between the v1.0 and beta
endpoints.
The only suggestion for you is to vote up the existing feature request in User Voice or submit a new one.
Thanks for pointing this out. As Seiya points out, /me/joinedTeams does not support the OData query parameters. The documentation suggested otherwise, I've made a doc fix that should propagate in the next day or two.

Unable to access the Sharepoint List using Microsoft Graph API--

Working with the Microsoft graph api and especially the sharepoint beta api and i am constantly running into issues. I know its beta, but still;)
SO the issue is When i tried to access the sharepoint list using Graph API in graph explorer
URL is: GET https://graph.microsoft.com/beta/sites/{site-id}/lists/{list-id}
So SiteID i am passing my site tenant GUID and List ID as Sharepoint List GUID
and i am facing the error continously in Response
{
"error": {
"code": "invalidRequest",
"message": "Provided id is not suitable for the current host",
"innerError": {
"request-id": "61efc5b1-88f8-442c-a41d-7213b587318e",
"date": "2017-05-10T07:38:04"
}
}
}
IF any one also has faced this issue please let me know the solution you have resolved
The format of the ID's for sites have changed as part of a set of updates to the API this week. The new format is documented here, but it includes the SharePoint hostname, SPSite.ID, and SPWeb.ID as a triplet:
https://graph.microsoft.com/beta/sites/contoso.sharepoint.com,fc016e3c-d8ae-4ee0-a10c-de6d26788b6a,9a4ea7a5-c3c4-44ae-9f80-273bd67431b8
If you add the hostname into your IDs, your calls should start working again. You can discover the hostname by making a request to:
https://graph.microsoft.com/beta/sites/root/siteCollection/hostname
You can also search for sites now using the following search syntax:
https://graph.microsoft.com/beta/sites?search={keyword}
#Ryan Gregg has the correct answer
The SiteId is not just one GUID but a combination of <HostName,SPSite.ID,SPWeb.ID>.
Example: <contoso.sharepoint.com,fc016e3c-d8ae-4ee0-a10c-de6d26788b6a,9a4ea7a5-c3c4-44ae-9f80-273bd67431b8>
The whole string in the above example is what you should pass for {SiteId} in your request
If you dont have the SPSite.ID but have the URL for the site, you can make a GRAPH API call with relative path to the site
https://graph.microsoft.com/v1.0/sites/contoso.sharepoint.com:/sites/Documetation
This call will return all the properties for the site and you can grab the full SiteId from here:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites/$entity",
"createdDateTime": "2020-04-23T12:18:48.653Z",
"description": "Documentation",
"id": "contoso.sharepoint.com,fc016e3c-d8ae-4ee0-a10c-de6d26788b6a,9a4ea7a5-c3c4-44ae-9f80-273bd67431b8",
"lastModifiedDateTime": "2020-12-09T19:17:21Z",
"name": "Documentation",
"webUrl": "https://contoso.sharepoint.com/sites/Documentation",
"displayName": "Documentation",
"root": {},
"siteCollection": {
"hostname": "contoso.sharepoint.com"
}
}
Try https://graph.microsoft.com/beta/sites/{siteCollectionId},{siteId}/lists
You can find these ids from https://graph.microsoft.com/beta/site/sites

Getting project category based on project key from jira rest api

We are developing a web project to get a list of project category for a particular project key for jira using their rest api and update it.
I can not find any appropriate api for the same.
Has anybody done something like this.
Thanks in advance.
The JIRA REST API documentation mentions this plain and simple.
Retrieving project info
Use GET /rest/api/2/project/{projectIdOrKey} to get details about a specific project. This response will also contain info about the project category, ie.:
"projectCategory": {
"self": "http://www.example.com/jira/rest/api/2/projectCategory/10000",
"id": "10000",
"name": "FIRST",
"description": "First Project Category"
}
Updating a project
To update the category, use PUT /rest/api/2/project/{projectIdOrKey}
You can include the id of the desired category in the request body, ie.:
{
"key": "EX",
"name": "Example",
"projectTypeKey": "business",
"projectTemplateKey": "com.atlassian.jira-core-project-templates:jira-core-project-management",
"description": "Example Project description",
"lead": "Charlie",
"url": "http://atlassian.com",
"assigneeType": "PROJECT_LEAD",
"avatarId": 10200,
"issueSecurityScheme": 10001,
"permissionScheme": 10011,
"notificationScheme": 10021,
"categoryId": 10120
}

Resources