MS Graph Client object's Request URL gets port 443 added

Nishant Lakhlani 0 Reputation points
2023-06-17T15:42:13.1+00:00

Not able to get my file list from Onedrive using GraphServiceClient. I am able to get User / Me related into, but when tried fetching list of files from my organization's OneDrive / SharePoint, it fails.

While debugging the code could see that GraphServiceClient RequestURL seems to be adding a port "443" in the URL to my code of fetching file list. But not sure is this the issue as the error shows "Item Not Found"

Note: I am using ASP.NET Core Web App and have registered API having "Files.ReadWrite" & "Sites.Read.All" permission for MS Graph enabled and used this API's Client in ASP.NET Core Web App

Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 46,406 Reputation points
    2023-06-19T06:58:29.2566667+00:00

    Hi @Nishant Lakhlani

    Can you share your test code? Make sure you are using the correct drive id/site id and item id in your code. Before running your project, use Postman or Graph Explorer to test it locally to see if it can return data correctly.

    Also refer to my sample snippet, it works fine:

    var graphClient = new GraphServiceClient(requestAdapter);
    
    try { 
    
    var result = await graphClient.Drives["{drive id}"].Items["{driveItem-id}"].Children.GetAsync();
    
    Console.WriteLine(result);
    
    }
    
    catch(ODataError odataError) {
    
        Console.WriteLine(odataError.Error.Code);
        Console.WriteLine(odataError.Error.Message);
    
    }
    

    5

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.