question

AlessandraBonomo-0503 avatar image
0 Votes"
AlessandraBonomo-0503 asked saldana-msft edited

GraphServiceClient - getting sharepoint folder data - gets stucked

I need to check if a a folder exists in sharepoint : if it doesn't exists I need to create it
This is my call:

Await graphClient.Sites(MySiteId).Drive.Items(MyFolderId).Request.GetAsync

If my MyFolderIdexists it all works fine, but if it doesn't exists the call remains stuck indefinitely

In general I notice that each time I make a graph call, using GraphClient, that looks for something that doesn't exists in sharepoint I get stucked
By now, not to block my application, I'm using a timeout, checking if the result status is RanToCompletion . But I can never know whether my call has an error, a simple timeout or a not found exception:
Dim itemsInFolderRequest = graphClient.Sites(SharePointSiteID).Drive.Items(SharePointParentFolderId).Children.Request
Dim itemsInFolder = itemsInFolderRequest.GetAsync
Await Task.WhenAny(itemsInFolder, Task.Delay(m_GraphRquestTimeoutMs))
If itemsInFolder IsNot Nothing AndAlso itemsInFolder.Status = Threading.Tasks.TaskStatus.RanToCompletion Then
'only here I'm sure I can read results
else
'here I don't know what happened
End If

Is there a way to make the
Await graphClient.Sites(MySiteId).Drive.Items(MyFolderId).Request.GetAsync
work without blocking, returning me a simple "Not found"?

windows-apimicrosoft-graph-sdk
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.

0 Answers