msgraph-sdk-dotnet icon indicating copy to clipboard operation
msgraph-sdk-dotnet copied to clipboard

Subscription GET Request Inconsistent

Open robertkitching opened this issue 8 years ago • 7 comments

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.

robertkitching avatar Mar 27 '18 14:03 robertkitching

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 QueryNotSupported response, 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.

mlafleur avatar Mar 27 '18 16:03 mlafleur

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/?

robertkitching avatar Mar 28 '18 09:03 robertkitching

Which Nuget package version are you using?

MIchaelMainer avatar Mar 28 '18 16:03 MIchaelMainer

Currently using 1.8.1.

Prior to the update I was using 1.7.0. Believe I have experienced the problem in both versions.

robertkitching avatar Mar 29 '18 09:03 robertkitching

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.

MIchaelMainer avatar Mar 29 '18 20:03 MIchaelMainer

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.

robertkitching avatar Apr 06 '18 10:04 robertkitching

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*/ ));

mlafleur avatar Apr 06 '18 14:04 mlafleur