0
votes

I tried to implement O365 unified api(beta version). I successfully got all the groups, However I faced problems when trying to get files of a particular group.

The error message is " UnAuthorized (401)" .

When I checked in fiddler it returns an error from server in webview.

I have already given permissions (read all site collections , all groups, all files), still file access is not working.

If anyone knows how to fix this please help me.

2

2 Answers

0
votes

First, let's ensure we are using the correct method:

As per the docs at https://msdn.microsoft.com/en-us/office/office365/howto/groups-rest-operations, ensure that you are using this method :

List all files and folders Get a list of all of the immediate files and folders in a group. Required scope: Group.Read.All

GET https://graph.microsoft.com/{version}/{tenant}/groups('{groupId}')/files

Response Returns the children collection of files and folders in the group, if successful. Note that this doesn't return the children of the immediate folders in the group.

Sample request

GET https://graph.microsoft.com/beta/contoso.com/groups('c75831bd-fad3-4191-9a66-280a48528679')/files

Second, Let's rule out some peculiarities of the API Preview/Beta mode:

Please review and validate the following 3 caveats against your testing scenario https://msdn.microsoft.com/en-us/office/office365/howto/office-365-rest-api-release-notes :

No instant access to content after creation

Unified groups can be created immediately through a POST on the group entity. However, for a unified group that is created through the unified API, access to the associated content will not be readily available. Apps will be able to start adding content to the group (files, conversations, and events) after a set period of time, as follows:

For conversations and events, up to 40 minutes after group creation
For files, up to 24 hours after group creation 

Until that time, attempts to update the unified group with content will result in a 500 HTTP error response. For proof-of-concept applications that are using the Office 365 unified APIs, we recommend that you use Outlook or Outlook Web App to create unified group if immediate access to the content is required.

Policy

Using the Office 365 unified APIs to create and name a unified group bypasses any unified group policies that are configured through Outlook Web App. For proof-of-concept applications that use the Office 365 unified APIs, we recommend that you use Outlook or Outlook Web App to create unified groups.

Permission scopes

The Office 365 unified API exposes two permission scopes for unified groups:

Group.Read.All
Group.ReadWrite.All 

These scopes provide access to group management functions (enumerating groups, enumerating group members) as well as access to content in the group (conversations and events). However, in order to access files in a unified group, you must also request the Sites.Read.All or Site.ReadWrite.All permission scope. For more information about these permission scopes, see Get started with Office 365 unified API (preview).

Finally, check if there's anything different about the Group you are querying against If you review the Group in Graph Explorer, do you see any differences in the group metadata between it and Groups elsewhere and outside of your testing tenancy? There may be a smoking gun property that stands out.

0
votes

Most likely, is because you don't have Site.Read.All permission, this is a temporary requirement to access group files.