Forum Discussion
Notifications with sendActivityNotification API
Request : https://graph.microsoft.com/v1.0/users/email address removed for privacy reasons/teamwork/sendActivityNotification --header 'Authorization: XXXXXXX' --header 'Content-Type: application/json' --header 'Accept: application/json'
Data : {"topic":{"source":"text","value":"New message","WebUrl":"https://teams.microsoft.com/l/entity/XXXX/YYY"},"activityType":"mldt_notify","previewText":{"content":"Check New Messaging"}}
Another observation API sometimes works and randomly gives below gives :
Application with AAD App Id 'XXXXXX' is not authorized to generate custom text notifications about '/v1.0/users/XXXXXX/teamwork/Microsoft.Teams.GraphSvc.sendActivityNotification' to the recipient. Ensure that the expected Teams app is installed in the target scope (user, team, or chat).
- Sayali-MSFTOct 03, 2022
Microsoft
Pratapkarn2186 -No need to assigning the app created to users. - Pratapkarn2186Oct 01, 2022Copper Contributor
- Sayali-MSFTSep 30, 2022
Microsoft
We tried with the manifest you shared it worked for us. Also included the request body you shared and changed team and user id's it also worked.
Can you try to change id in your manifest and see all old instances are deleted.
Also got the related thread -
https://stackoverflow.com/questions/66346794/application-with-aad-app-id-is-not-authorized-to-generate-notifications-about - Pratapkarn2186Sep 28, 2022Copper Contributor
Sayali-MSFT: Did you get a chance to look Manifest file. - Pratapkarn2186Sep 27, 2022Copper Contributor
- Pratapkarn2186Sep 27, 2022Copper Contributor
Please find the manifest file.
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.14/MicrosoftTeams.schema.json",
"version": "1.0.1",
"manifestVersion": "1.14",
"id": "xxxxx-xxx-xxx-xxxx-vvvvvvvv",
"packageName": "com.package.name",
"name": {
"short": "Vavmex-500",
"full": ""
},
"developer": {
"name": "xxxx",
"mpnId": "",
"websiteUrl": "https://xxxxx.ai",
"privacyUrl": "https://xxxxx.ai",
"termsOfUseUrl": "https://xxxx.ai/t&c"
},
"description": {
"short": "Messaging App",
"full": "Application is used to send and receive messages"
},
"icons": {
"outline": "outline.png",
"color": "color.png"
},
"accentColor": "#FFFFFF",
"staticTabs": [
{
"entityId": "xxxxx-xxxx-xxxx-xxx-xxxxxxx",
"name": "MultiLine",
"contentUrl": "https://xxxxx.xxxxxx.net ",
"scopes": [
"personal"
]
},
{
"entityId": "about",
"scopes": [
"personal"
]
}
],
"validDomains": [
"xxxxx.xxxxx.net"
],
"webApplicationInfo": {
"id": "xxxxx-393c-xxxx-930b-xxxxxxxxx",
"resource": "api://xxxxxx.xxxxx.net/xxxxx-393c-47c5-xxxx-xxxxx"
},
"isFullScreen": true,
"activities": {
"activityTypes": [
{
"type": "notify",
"description": "Notification",
"templateText": "MultiLine"
}
]
}
}
- Sayali-MSFTSep 27, 2022
Microsoft
Pratapkarn2186-Could you please share the manifest json , So that we can try it from our end and let you know. - Pratapkarn2186Sep 27, 2022Copper Contributor
Sayali-MSFT: I tried with the postman and got an error.
API Request: https://graph.microsoft.com/v1.0/users/xxxxx/teamwork/sendActivityNotification
Response:
{
"error": {
"code": "Forbidden",
"message": "Application with AAD App Id 'xxxxxxx' is not authorized to generate custom text notifications about '/v1.0/users/xxxxx/teamwork/Microsoft.Teams.GraphSvc.sendActivityNotification' to the recipient. Ensure that the expected Teams app is installed in the target scope (user, team, or chat).",
"innerError": {
"date": "2022-09-27T07:59:00",
"request-id": "c52396c3-54cf-4050-b861-6ee5b102519c",
"client-request-id": "c52396c3-54cf-4050-b861-6ee5b102519c"
}
}
} - Sayali-MSFTSep 26, 2022
Microsoft
Pratapkarn2186 - Have you try to test your API using Postman tool?
- Pratapkarn2186Sep 26, 2022Copper Contributor
The app is published in personal scope, then I search for the application and just add.
I don't see any option for scope, but it says "works in Teams"
Is something else that needs to be done ?? - Sayali-MSFTSep 26, 2022
Microsoft
Pratapkarn2186 - Could you please create a new app and install the app in relevant scope (teams or group chat) to make the API work.
Also the API requires few application level permissions to work.
While testing it using Graph Explorer, it will create its own app id that is not related to actual app, that's why it is causing forbidden error. Could you please try to test your API using Postman tool.