question

OliverMario-7381 avatar image
0 Votes"
OliverMario-7381 asked saldana-msft edited

General question about file search with graph

Hello, once again I have a question about the MS Graph SDK for ASP Net Core (C#):

Do I have to be logged in to start the search from Files(One Drive) ? Or is this also possible as daemon-services (like webhooks with MS Graph)(not delegated) ?

About answer I would be very happy




microsoft-graph-filesmicrosoft-graph-search
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JosephXu-MSFT avatar image
0 Votes"
JosephXu-MSFT answered JosephXu-MSFT commented

Hi @OliverMario-7381 Yes, we can search Files in One Drive without logged in.


  1. To do that we need to add app permissions. The permissions are shown in the figure below.
    123428-image.png


  2. Then click Grant admin content for ...
    123446-image.png
    Or use the tenant-wide admin consent URL follows the following format:

https://login.microsoftonline.com/{tenant-id}/adminconsent?client_id={client-id}




image.png (28.4 KiB)
image.png (35.2 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Update:

You know what's crazy I didn't change anything in the code or reporting (I swear !!!!!) and it works ? But why does it work now ?! :-D :-) :-O

Three days I have researched and tried and now it works without what I have changed!^^

1 Vote 1 ·

Hi @OliverMario-7381 Glad to hear you got it works. It should be that your app permissions have been approved by the tenant administrator.

0 Votes 0 ·
OliverMario-7381 avatar image
0 Votes"
OliverMario-7381 answered JosephXu-MSFT edited

Hello and thank you for your answer,

I have the problem with my daemon application that when I want to search a special folder for a file the count is always 0.
By the way, I can still run a webhook (with delta query) with my Deamon application.

  private async Task<IDriveItemSearchCollectionPage> SearchFiles(GraphServiceClient graphClient){
   var search = await graphClient.Drives["{Drive-id}"]
                                  .Items["{user-id]"]
                                  .Search("Filename") //todo
                                  .request()
                                  .GetAsync();
        
      return search;
  }
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Maybe you passed wrong value to Items["{user-id]"]. This should be id of the folder. You can use /drives/{drive-id}/root/children to find the folder id. Then replace the user-id with your folder-id. So you should use this uri /users/{user-id}/drives/{drive-id}/items/{folder-id}/children.

0 Votes 0 ·

Hi @OliverMario-7381 If there's anything you'd like to know, don't hesitate to ask.


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

0 Votes 0 ·