Subscription GET Request Inconsistent
Currently using .NET Core 2.0.
When attempting to pull all the current subscriptions associated with my tenant I get inconsistent results
I am using the below line:
await client.Subscriptions.Request().GetAsync()
Sometimes I get the result returned as expected IEnumerable<Subscription> either populated or empty.
Other times I receive the following error message..
Code: QueryNotSupported Message: Get Subscriptions list is not supported for the API version 1.0.
The result depends on the Microsoft Graph "version" you're targeting:
-
When you're getting back an empty
IEnumerable<Subscription>response, you're hitting the/beta/version. -
When you're getting back the
QueryNotSupportedresponse, you're hitting the/v1.0/version.
v1.0 doesn't support returning a collection of subscription resources and the URI https://graph.microsoft.com/v1.0/subscriptions isn't a valid endpoint.
The Beta version seems to work differently in that it returns an empty array instead of an error. It isn't clear however if this is a bug or a stub for future changes as there isn't any documentation for a "List Subscriptions" method at the moment. Based on my limited testing, it does seem to always return an empty array today.
Great, thanks for the detailed information! I believed I was targeting the default version and this was not changed between tests.
Would you have any idea why the default version would alter between beta and /v1.0/?
Which Nuget package version are you using?
Currently using 1.8.1.
Prior to the update I was using 1.7.0. Believe I have experienced the problem in both versions.
The default version is v1.0 for the client library. Are you able to repro the issue? If so, can you share a sanitized Fiddler capture? I don't think this is a client library issue.
Apologies for the delay I have been on holiday.
I now am unable to recreate, it is always resolving to version 1.0 which does not have the required method. Up until a few weeks ago it must have been defaulting to beta as the method worked as expected throughout testing.
How would I specify the version used? I altered the app settings from "GraphResourceId": "https://graph.microsoft.com/", to "GraphResourceId": "https://graph.microsoft.com/beta", but it threw an expection.
The GraphResourceId should remain https://graph.microsoft.com/. Two switch API versions you need to specify https://graph.microsoft.com/beta as the GraphServiceClient.BaseUrl:
var graphClient = new GraphServiceClient(
"https://graph.microsoft.com/beta",
new DelegateAuthenticationProvider( /*auth provider settings*/ ));