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

如何在Microsoft Graph中检索现有订阅?调用接口遇QueryNotSupported错误

Fixing the QueryNotSupported Error When Retrieving Microsoft Graph Subscriptions

Got it, that QueryNotSupported error you're hitting when fetching subscriptions via the .NET SDK is almost always tied to permission issues or missing configuration. Let's break down the fixes step by step:

1. Verify Your App's Permission Configuration

First, make sure your registered app has the right permissions assigned, and that admin consent has been granted (if required):

  • Delegated Permissions: You'll need either Directory.Read.All or Subscription.Read.All. Also, note that for delegated access in v1.0, the signed-in user must be a Global Administrator, Global Reader, or Subscription Administrator.
  • Application Permissions: Use Subscription.Read.All, and this must be explicitly granted by an admin (you can't use user consent for application-level permissions).

2. Check the Scope in Your Token Request

When initializing your GraphServiceClient, ensure the access token you're requesting includes the necessary scope. For example:

// Example for delegated permissions
var scopes = new[] { "https://graph.microsoft.com/Subscription.Read.All" };
// Initialize your auth provider with these scopes
var authProvider = new InteractiveAuthenticationProvider(clientId, scopes);
var graphClient = new GraphServiceClient(authProvider);

3. Validate Your SDK Call and Version

Your code var subscriptions = await graphServiceClient.Subscriptions.Request().GetAsync(); is syntactically correct, but double-check:

  • You're using a stable, up-to-date version of the Microsoft Graph .NET SDK. Older versions might have compatibility issues with the v1.0 endpoint.
  • Decode your access token (using a tool like jwt.io) to confirm the scp (for delegated) or roles (for application) claims include the required permission. If the permission isn't present, your token request is missing the scope.

Quick Test to Rule Out SDK Issues

If you're still stuck, try calling the REST endpoint directly to eliminate SDK-related problems:

GET https://graph.microsoft.com/v1.0/subscriptions
Authorization: Bearer {your-access-token}

If this REST call fails with the same error, the issue is definitely in your app's permissions or configuration. If it succeeds, update your .NET SDK to the latest version and recheck your client initialization code.


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 04:31:05