-1

I want to get messages from teams public channel. I can get messages from the one which I am part of, but i want to retrieve messages from public channel which i am not part of.

There are few apis available on microsoft: https://learn.microsoft.com/en-us/graph/api/channel-list-messages?view=graph-rest-1.0&tabs=http https://learn.microsoft.com/en-us/graph/api/chatmessage-delta?view=graph-rest-1.0&tabs=http

I created a app with all the appropriate application permissions. I also requested for protected apis request from microsoft(https://learn.microsoft.com/en-us/graph/teams-protected-apis).

But i still cannot get all the public channel messages and keep getting below error:

"response": {
    "error": {
        "code": "Forbidden",
        "message": "UnknownError",
        "innerError": {
            "date": "2022-06-30T00:48:11",
            "request-id": "25360f0f-xxxx-xxxx-xxxx-78fa36f30f1c",
            "client-request-id": "25360f0f-xxxx-xxxx-xxxx-78fa36f30f1c"
        }
    }
}

any help will be much appriciated.

2 Answers2

0

Could you please try to decode the access token in jwt.io and make sure you have at least ChannelMessage.Read.All permission to read the message , if the you don't have the required permission , please add it again and try to check in graph explorer first, if its working fine .

Thanks

vicky kumar
  • 563
  • 3
  • 11
  • i can see that permission. The thing is i can get messages from channel which i am part of but i want to retrieve messages from channel(public) which i am not part of. – Ashish Mittal Jun 30 '22 at 11:27
  • Oh , thanks for the update , in that case you should ask someone to add you in that channel , POST https://graph.microsoft.com/v1.0/teams/ece6f0a1-7ca4-498b-be79-edf6c8fc4d82/channels/19%3A56eb04e133944cf69e603c5dac2d292e%40thread.skype/members Content-type: application/json { "@odata.type": "#microsoft.graph.aadUserConversationMember", "roles": [" "], "user@odata.bind": "https://graph.microsoft.com/v1.0/users('8b081ef6-4792-4def-b2c9-c363a1bf41d5')" } , ref doc - https://learn.microsoft.com/en-us/graph/api/channel-post-members?view=graph-rest-1.0&tabs=http#request – vicky kumar Jun 30 '22 at 16:48
  • is there any way I can get messages without getting added to that team/channel? Using an app or any other way that Microsoft allow. – Ashish Mittal Jun 30 '22 at 17:35
0

GET /teams/team-id/ is accessible only to team members or owner or admin. Only a person who is part of the team's roster or is an Admin (Global Admin or Teams Service Admin or AU Admin) can see anything under GET /teams/team-id/.

Even Admins cannot pull messages from channels they are not part of. That is by design.

Meghana-MSFT
  • 595
  • 3
  • 7