Unable to get attachments from a group conversation

Olivier-7208 6 Reputation points
2021-05-04T09:59:24.093+00:00

I want to get the attachments of a post that is part of a group conversation.
The application has the following permissions: Type: Application, Group.Read.All, Group.ReadWrite.All

93566-capture-decran-2021-05-04-a-120743.png

            app = ConfidentialClientApplicationBuilder.Create(config.ClientId)  
                .WithClientSecret(config.ClientSecret)  
                .WithAuthority(new Uri(config.Authority))  
                .Build();  

            string[] scopes = new string[] {$"{config.ApiUrl}/.default"};  
  
config.ApiUrl : "https://graph.microsoft.com/"  


            LogHelper.Info("Conversations...");  
            await apiCaller.CallWebApiAndProcessResultASync($"{config.ApiUrl}v1.0/groups/{groupId}", result.AccessToken,  
                 Display);  

             LogHelper.Info("Posts...");  
             await apiCaller.CallWebApiAndProcessResultASync($"{config.ApiUrl}v1.0/groups/{groupId}/threads/{threadId}/posts/", result.AccessToken,  
                 Display);       
  
             LogHelper.Info("Attachments...");  
             await apiCaller.CallWebApiAndProcessResultASync($"{config.ApiUrl}v1.0/groups/{groupId}/threads/{threadId}/posts/{postId}/attachments", result.AccessToken,  
                 Display);  

I get the group and the posts. But it has an error for the attachments:
Failed to call the web API: Forbidden
Content: {"error":{"code":"ErrorAccessDenied","message":"Access is denied. Check credentials and try again."}}

Unable to get attachments from a group conversation

According to the documentation, if I have the rights to the posts and the group then I should have the rights to the attachments.
https://learn.microsoft.com/en-us/graph/api/post-list-attachments?view=graph-rest-1.0&tabs=http

Why don't I have the rights?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,573 questions
{count} vote

1 answer

Sort by: Most helpful
  1. CharanyaB-MSFT 1,421 Reputation points Microsoft Vendor
    2024-02-13T22:19:46.44+00:00

    Hello @Olivier-7208 ,

    Thank you for reaching Microsoft.

    I can see that you are using application permission for this API, this works with getting the posts of the specified thread. But as mentioned in the document, retrieving the attachments from a post works with only Delegated permissions. User's image

    As seen from the above table, application permission is not supported to get the post attachments. I suggest you to consent the required delegated permission and use the API.

    Documentation: https://learn.microsoft.com/en-us/graph/api/post-list-attachments?view=graph-rest-1.0&tabs=http

    Hope this helps. If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.