You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将Microsoft Graph学习路径代码从v1.0切换至Beta版本?

Fixing "Resource not found" when fetching user photo with Microsoft Graph v1.0 (switch to Beta)

Hey there! Let's sort out that frustrating "Resource not found" error you're getting when trying to pull a user's photo via Microsoft Graph v1.0. It makes total sense that the Beta version works while v1.0 doesn't—sometimes the v1.0 endpoint lags behind on certain features, especially for personal accounts or specific tenant configurations, and the learning path you're following is likely outdated.

Here's how to modify your code to use the Beta version instead of v1.0:

First, let's focus on where your requestUserPhoto object is being created. The core change is swapping the API version from v1.0 to beta in your Graph request.

Option 1: Update your Graph Service Client to use Beta globally

If you're using the Microsoft Graph SDK, the easiest way is to initialize your GraphServiceClient with the Beta endpoint as the base URL. This will make all your requests use Beta by default:

// Replace your existing GraphClient initialization with this
var graphClient = new GraphServiceClient(authProvider, "https://graph.microsoft.com/beta");

Then your existing photo request code can stay mostly the same—since the client now points to Beta, it'll hit the correct endpoint:

var requestUserPhoto = graphClient.Me.Photo.Content.Request();
var resultsUserPhoto = requestUserPhoto.GetAsync().Result;

Option 2: Target Beta for just the photo request

If you don't want to switch all your requests to Beta, you can override the URL specifically for the photo call:

// Build a direct request to the Beta endpoint for the user photo
var requestUserPhoto = graphClient.Me.Photo.Content.Request().WithUrl("https://graph.microsoft.com/beta/me/photo/$value");
var resultsUserPhoto = requestUserPhoto.GetAsync().Result;

A quick note about Beta:

Keep in mind that the Microsoft Graph Beta endpoint is for preview features—Microsoft might change or remove functionality without warning. It's great for testing or completing your learning path, but you'll want to switch back to v1.0 once the feature is officially released there (if that's important for production use).

That should resolve the "Resource not found" error and let you fetch the user's photo successfully!

内容的提问来源于stack exchange,提问作者MrFabou

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 07:46:41