Hi,
I am using the Microsoft Graph 'Shared With Me' API to fetch all shared files using Client Secret Flow for authentication. Below is the relevant part of my code. However, when I execute the 'Shared With Me' API, I receive a Bad Request error (below image). All other APIs, such as 'Get Drive' and 'Drive Items', are working fine. Could you help me understand what might be causing this issue or if I’m missing something?
Working API:
DriveItem driveRoot = await graphClient.Drives[DriveId].Root.GetAsync();
DriveItemCollectionResponse driveItems = await graphClient.Drives[DriveId].Items[driveRoot.Id].Children.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Expand = new string[] { "thumbnails" };
});
Not Working API:
SharedWithMeResponse sharedItems = await graphClient.Drives[DriveId].SharedWithMe.GetAsync();
private GraphServiceClient graphClient;
private void setGraphClientForAppAuth()
{
var options = new TokenCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
};
clientSecretCredential = new ClientSecretCredential(
_teamsSettings.tenant, _teamsSettings.clientId, _teamsSettings.appkey, options);
graphClient = new GraphServiceClient(clientSecretCredential);
}
SharedWithMeResponse sharedItems = await graphClient.Drives[DriveId].SharedWithMe.GetAsync();