Teams REST API - Reading channel messages in a team channel - Unknown Error

%3CLINGO-SUB%20id%3D%22lingo-sub-362734%22%20slang%3D%22en-US%22%3ETeams%20REST%20API%20-%20Reading%20channel%20messages%20in%20a%20team%20channel%20-%20Unknown%20Error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-362734%22%20slang%3D%22en-US%22%3E%3CP%3EHey%20All%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20writing%20an%20application%20that%20uses%20the%20Microsoft%20Graph%20API%20as%20an%20Application%20(rather%20than%20a%20User%20delegation).%20I'm%20trying%20pull%20the%20content%20of%20channel%20by%20using%20something%20of%20the%20form%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3Ehttps%3A%2F%2Fgraph.microsoft.com%2Fbeta%2Fteams%2F***5191cfdac137%2Fchannels%2F****d76a771b1e34bd187fd%40thread.skype%2Fmessages%3C%2FPRE%3E%3CP%3EI%20can%20read%20the%20top%20level%20content%20of%20the%20channel%20to%20get%20the%20display%20name%20fine%20but%20when%20I%20try%20and%20read%20the%20messages%20content%20I%20get%20this%20unknown%20error%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%7B%0A%20%20%20%20%22error%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22code%22%3A%20%22UnknownError%22%2C%0A%20%20%20%20%20%20%20%20%22message%22%3A%20%22%22%2C%0A%20%20%20%20%20%20%20%20%22innerError%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22request-id%22%3A%20%22614dcb07-d055-4a72-99f7-dafbc59f5293%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22date%22%3A%20%222019-03-07T14%3A56%3A37%22%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%7D%3C%2FPRE%3E%3CP%3EI%20notice%20that%20some%20of%20the%20documentation%20says%20I%20can't%20do%20this%20an%20application%2C%20but%20some%20of%20it%20says%20if%20I%20have%20the%20permission%20%22ChannelMessage.Read.All%22%20it%20should%20work.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20anyone%20point%20me%20at%20either%20how%20to%20determine%20what%20this%20%22Unknown%20Error%22%20is%20or%20whether%20this%20is%20possible%20using%20the%20bata%20APIs%20or%20not%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20help%20much%20appreciated%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECheers%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EKev%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-362734%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-382991%22%20slang%3D%22en-US%22%3ERe%3A%20Teams%20REST%20API%20-%20Reading%20channel%20messages%20in%20a%20team%20channel%20-%20Unknown%20Error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-382991%22%20slang%3D%22en-US%22%3E%3CP%3Ehi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F296997%22%20target%3D%22_blank%22%3E%40kevglass%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eatm%20you%20need%20to%20be%20member%20of%20the%20team%20in%20order%20to%20read%20channel%20messages%20via%20the%20api.%3C%2FP%3E%3CP%3EMS%20is%20working%20on%20application%20permission%20support%20which%20will%20give%20you%20access%20to%20all%20channels%20in%20your%20tenant%20without%20the%20need%20of%20being%20a%20member%20of%20any%20team%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Esee%3A%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FMicrosoft-Teams-AMA%2FList-of-channel-messages%2Fm-p%2F339514%23M4134%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FMicrosoft-Teams-AMA%2FList-of-channel-messages%2Fm-p%2F339514%23M4134%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ehope%20this%20helps%3C%2FP%3E%3CP%3Estefan%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-362871%22%20slang%3D%22en-US%22%3ERe%3A%20Teams%20REST%20API%20-%20Reading%20channel%20messages%20in%20a%20team%20channel%20-%20Unknown%20Error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-362871%22%20slang%3D%22en-US%22%3E%3CP%3EAh%20yes%2C%20so%20you're%20using%20Delegation%20of%20permissions%20for%20a%20specific%20users%20through%20OAuth.%20I'm%20trying%20to%20use%20Application%20auth%20with%20no%20user%20associated.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECheers%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EKev%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-362866%22%20slang%3D%22en-US%22%3ERe%3A%20Teams%20REST%20API%20-%20Reading%20channel%20messages%20in%20a%20team%20channel%20-%20Unknown%20Error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-362866%22%20slang%3D%22en-US%22%3ENo%20ChannelMessages.Read.All.%20Only%3A%20offline_access%2C%20openid%2C%20profile%2C%20Group.ReadWrite.All%2C%20User.Read.All.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-362857%22%20slang%3D%22en-US%22%3ERe%3A%20Teams%20REST%20API%20-%20Reading%20channel%20messages%20in%20a%20team%20channel%20-%20Unknown%20Error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-362857%22%20slang%3D%22en-US%22%3E%3CP%3EYep%2C%20channels%20work%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3Ehttps%3A%2F%2Fgraph.microsoft.com%2Fbeta%2Fteams%2F8b455bd2-b0ca-46ce-9d3f-5191cfdac137%2Fchannels%2F19%3A3cd4d4c2d2af4d76a771b1e34bd187fd%40thread.skype%0A%0A%7B%22%40odata.context%22%3A%22https%3A%2F%2Fgraph.microsoft.com%2Fbeta%2F%24metadata%23teams('8b455bd2-b0ca-46ce-9d3f-5191cfdac137')%2Fchannels%2F%24entity%22%2C%22id%22%3A%2219%3A3cd4d4c2d2af4d76a771b1e34bd187fd%40thread.skype%22%2C%22displayName%22%3A%22General%22%2C%22description%22%3A%22Our%20testing%20team%22%2C%22isFavoriteByDefault%22%3Anull%2C%22email%22%3A%22%22%2C%22webUrl%22%3A%22https%3A%2F%2Fteams.microsoft.com%2Fl%2Fchannel%2F19%253a3cd4d4c2d2af4d76a771b1e34bd187fd%2540thread.skype%2FGeneral%3FgroupId%3D8b455bd2-b0ca-46ce-9d3f-5191cfdac137%26amp%3BtenantId%3D02746fc5-37cd-4f42-9151-465b7d8eb31b%22%7D%0A%0Ahttps%3A%2F%2Fgraph.microsoft.com%2Fbeta%2Fteams%2F8b455bd2-b0ca-46ce-9d3f-5191cfdac137%2Fchannels%2F19%3A3cd4d4c2d2af4d76a771b1e34bd187fd%40thread.skype%2Fmessages%0A%0A%7B%0A%20%20%22error%22%3A%20%7B%0A%20%20%20%20%22code%22%3A%20%22UnknownError%22%2C%0A%20%20%20%20%22message%22%3A%20%22%22%2C%0A%20%20%20%20%22innerError%22%3A%20%7B%0A%20%20%20%20%20%20%22request-id%22%3A%20%220cc324db-1b72-4428-9add-96aaf25e5b4e%22%2C%0A%20%20%20%20%20%20%22date%22%3A%20%222019-03-07T17%3A19%3A12%22%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%3C%2FPRE%3E%3CP%3EAre%20you%20using%20the%20Application%20Auth%20and%20the%20ChannelMessages.Read.All%20scope%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EKev%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-362848%22%20slang%3D%22en-US%22%3ERe%3A%20Teams%20REST%20API%20-%20Reading%20channel%20messages%20in%20a%20team%20channel%20-%20Unknown%20Error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-362848%22%20slang%3D%22en-US%22%3E%3CP%3EKev%2C%20I%20have%20a%20similar%20issue%20with%20another%20request.%20May%20I%20ask%20you%20to%20check%20%60%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgraph.microsoft.com%2Fbeta%2Fgroups%2F%7Bteam_id%7D%2Fchannels%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgraph.microsoft.com%2Fbeta%2Fgroups%2F%7Bteam_id%7D%2Fchannels%3C%2FA%3E%3C%2FSPAN%3E%60.%20Does%20it%20work%20for%20you%20with%20your%20team%20id%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-362845%22%20slang%3D%22en-US%22%3ERe%3A%20Teams%20REST%20API%20-%20Reading%20channel%20messages%20in%20a%20team%20channel%20-%20Unknown%20Error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-362845%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20executed%20a%20similar%20request%20with%20my%20ids%20and%20it%20works.%20Maybe%20there%20is%20an%20issue%20with%20your%20set%20up.%20I%20think%20you%20need%20to%20recheck%20all%20ids%20and%20token%20or%20try%20with%20a%20different%20team%2Fchannel.%20This%20is%20a%20valid%20request%20%60%3CA%20href%3D%22https%3A%2F%2Fgraph.microsoft.com%2Fbeta%2Fteams%2F%7Bteam_id%7D%2Fchannels%2F%7Bchannel_id%7D%2Fmessages%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgraph.microsoft.com%2Fbeta%2Fteams%2F%7Bteam_id%7D%2Fchannels%2F%7Bchannel_id%7D%2Fmessages%3C%2FA%3E%60%20and%20your%20ids%20looks%20valid%20as%20well.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-362736%22%20slang%3D%22en-US%22%3ERe%3A%20Teams%20REST%20API%20-%20Reading%20channel%20messages%20in%20a%20team%20channel%20-%20Unknown%20Error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-362736%22%20slang%3D%22en-US%22%3E%3CP%3EHaving%20dug%20a%20little%20more%20I%20can%20see%20the%20HTTP%20status%20code%20is%20401%20-%20presumably%20unauthorised%20in%20some%20way.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20the%20question%20is%3A%20Is%20there%20a%20way%20I%20can%20read%20channel%20messages%20with%20an%20application%20through%20the%20beta%20API%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECheers%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EKev%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-843150%22%20slang%3D%22en-US%22%3ERe%3A%20Teams%20REST%20API%20-%20Reading%20channel%20messages%20in%20a%20team%20channel%20-%20Unknown%20Error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-843150%22%20slang%3D%22en-US%22%3E%3CP%3EAs%20per%20Documentation%2C%20all%20api's%20related%20to%20messaging%20are%20protected%20api's.%20If%20you%20are%20planning%20to%20use%20them%20with%20App%20Permissions%20you%20need%20to%20get%20permission%20from%20Microsoft.%20PFB%20link%20for%20more%20details.%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fteams-protected-apis%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fteams-protected-apis%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hey All,

 

I'm writing an application that uses the Microsoft Graph API as an Application (rather than a User delegation). I'm trying pull the content of channel by using something of the form:

 

https://graph.microsoft.com/beta/teams/***5191cfdac137/channels/****d76a771b1e34bd187fd@thread.skype/messages

I can read the top level content of the channel to get the display name fine but when I try and read the messages content I get this unknown error:

 

{
    "error": {
        "code": "UnknownError",
        "message": "",
        "innerError": {
            "request-id": "614dcb07-d055-4a72-99f7-dafbc59f5293",
            "date": "2019-03-07T14:56:37"
        }
    }
}

I notice that some of the documentation says I can't do this an application, but some of it says if I have the permission "ChannelMessage.Read.All" it should work.

 

Can anyone point me at either how to determine what this "Unknown Error" is or whether this is possible using the bata APIs or not?

 

Any help much appreciated,

 

Cheers

 

Kev

8 Replies
Highlighted

Having dug a little more I can see the HTTP status code is 401 - presumably unauthorised in some way. 

 

So the question is: Is there a way I can read channel messages with an application through the beta API?

 

Cheers

 

Kev

Highlighted

I have executed a similar request with my ids and it works. Maybe there is an issue with your set up. I think you need to recheck all ids and token or try with a different team/channel. This is a valid request `https://graph.microsoft.com/beta/teams/{team_id}/channels/{channel_id}/messages` and your ids looks valid as well.

Highlighted

Kev, I have a similar issue with another request. May I ask you to check `https://graph.microsoft.com/beta/groups/{team_id}/channels`. Does it work for you with your team id?

 

Thanks.

Highlighted

Yep, channels work:

 

https://graph.microsoft.com/beta/teams/8b455bd2-b0ca-46ce-9d3f-5191cfdac137/channels/19:3cd4d4c2d2af4d76a771b1e34bd187fd@thread.skype

{"@odata.context":"https://graph.microsoft.com/beta/$metadata#teams('8b455bd2-b0ca-46ce-9d3f-5191cfdac137')/channels/$entity","id":"19:3cd4d4c2d2af4d76a771b1e34bd187fd@thread.skype","displayName":"General","description":"Our testing team","isFavoriteByDefault":null,"email":"","webUrl":"https://teams.microsoft.com/l/channel/19%3a3cd4d4c2d2af4d76a771b1e34bd187fd%40thread.skype/General?groupId=8b455bd2-b0ca-46ce-9d3f-5191cfdac137&tenantId=02746fc5-37cd-4f42-9151-465b7d8eb31b"}

https://graph.microsoft.com/beta/teams/8b455bd2-b0ca-46ce-9d3f-5191cfdac137/channels/19:3cd4d4c2d2af4d76a771b1e34bd187fd@thread.skype/messages

{
  "error": {
    "code": "UnknownError",
    "message": "",
    "innerError": {
      "request-id": "0cc324db-1b72-4428-9add-96aaf25e5b4e",
      "date": "2019-03-07T17:19:12"
    }
  }
}

Are you using the Application Auth and the ChannelMessages.Read.All scope?

 

Kev

Highlighted
No ChannelMessages.Read.All. Only: offline_access, openid, profile, Group.ReadWrite.All, User.Read.All.
Highlighted

Ah yes, so you're using Delegation of permissions for a specific users through OAuth. I'm trying to use Application auth with no user associated. 

 

Cheers

 

Kev

Highlighted

hi @kevglass 

 

atm you need to be member of the team in order to read channel messages via the api.

MS is working on application permission support which will give you access to all channels in your tenant without the need of being a member of any team

 

see:

https://techcommunity.microsoft.com/t5/Microsoft-Teams-AMA/List-of-channel-messages/m-p/339514#M4134

 

hope this helps

stefan

Highlighted

As per Documentation, all api's related to messaging are protected api's. If you are planning to use them with App Permissions you need to get permission from Microsoft. PFB link for more details.

https://docs.microsoft.com/en-us/graph/teams-protected-apis