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

调用_graphServiceClient.Me.GetAsync()报错:IUserRequestBuilder无GetAsync定义

问题解决:IUserRequestBuilder 不包含 GetAsync 定义

错误原因

你使用的Microsoft.Graph 4.x版本中,_graphServiceClient.Me对应的IUserRequestBuilder接口并没有GetAsync()方法,该方法属于请求实例(IUserRequest),而非请求构建器。

修正代码

将原代码:

var user = await _graphServiceClient.Me.GetAsync();

修改为:

var user = await _graphServiceClient.Me.Request().GetAsync();

额外检查项

  • 确认配置文件中DownstreamApi:Scopes包含用户读取权限(例如User.Read),否则会触发权限不足的错误。
  • 你的NuGet包版本组合(Microsoft.Identity.Web 2.17.5 + Microsoft.Identity.Web.MicrosoftGraph 2.17.5 + Microsoft.Graph 4.36.0)是兼容的,无需调整版本,核心问题仅为API调用语法不匹配。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.25 21:03:14