ErrorNonExistentStorage: Acessing service failed when loading user photo

Peter Dräxler 0 Reputation points
2025-02-13T06:29:30.6233333+00:00

I'm loading user's photo using .NET client for Microsoft Graph:

Stream? pictureStream = await graphClient.Users[adminID].Photo.Content.GetAsync()

The graph client does have the necessary permissions:

User's image

But I am getting an exception with message "Accessing service failed" and error code "ErrorNonExistentStorage". Is this a bug?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,049 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yakun Huang-MSFT 9,935 Reputation points Microsoft Vendor
    2025-02-13T08:13:32.2533333+00:00

    Hello Peter Dräxler,

    Thank you for reaching out to Microsoft Support!

    For your question, we did the same test, but the test results are all good, the test code is as follows:

    var photoStream = await graphClient.Users["******@xxxxxxxxxxxxx.OnMicrosoft.com"].Photo.Content.GetAsync();
    // Step 2: Save the photo to a file
    using (var fileStream = new FileStream("photo.jpg", FileMode.Create, FileAccess.Write))
    {
        await photoStream.CopyToAsync(fileStream);
    }
    // Step 3: Print the photo
    System.Drawing.Printing.PrintDocument printDocument = new System.Drawing.Printing.PrintDocument();
    printDocument.PrintPage += (sender, e) =>
    {
        System.Drawing.Image image = System.Drawing.Image.FromFile("photo.jpg");
        e.Graphics.DrawImage(image, new Point(0, 0));
    };
    printDocument.Print();
    

    For your error, it is recommended that you check whether the user_id is correct, according to the documentation needs to note the following:

    User's image

    Finally, you can test it in Graph Explorer to see if you get the same error.

    Hope this helps.

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


Your answer

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