1
votes

The following code segment using Microsoft Graph Client Library fails while trying to access One Drive contents

var items = Graphclient.Me.Drive.Root.Children.Request().GetAsync().Result;

It throws the exception

Code: BadRequest Message: Unable to retrieve user's mysite URL.

Fiddler shows an HTTP 400 for the request header. GET /v1.0/me/drives

I checked in Graph explorer and the tenant does work for the same request so why does it fail in code.

I have set the following admin level app permissions Directory.ReadWrite.All, Files.ReadWrite.All, Sites.ReadWrite.All, User.ReadWrite.All

The following sections of code do work

IGraphServiceDrivesCollectionPage drives = 
Graphclient.Drives.Request().GetAsync().Result;

Fiddler request - GET /v1.0/drives HTTP/1.1

So what am I missing when I am trying to access Graphclient.Me

1
any updates? Is it working yet? - user2810895
No it is not working - Codecrasher99

1 Answers

1
votes

Could you post the scopes from your jwt? The fact that graph explorer is able to execute the exact same call, implies it must be a permissions issue.

I know it sounds silly, but make sure you click the "grant permissions" button after you set permissions that require admin consent.