microsoftgraph / msgraph-sdk-dotnet

Microsoft Graph Client Library for .NET!
https://graph.microsoft.com
Other
690 stars 246 forks source link

choose api-version to target #55

Closed tjaisson closed 7 years ago

tjaisson commented 7 years ago

I had azure ad api call failures and solved it adding api-version query parameter using this code But I guess there is a cleaner way to achieve this.

GraphServiceClient GraphServiceClient = new GraphServiceClient("https://graph.windows.net/" + TenantId, new DelegateAuthenticationProvider( (requestMessage) => { requestMessage.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", accessToken); UriBuilder ub = new UriBuilder(requestMessage.RequestUri); System.Collections.Specialized.NameValueCollection query = HttpUtility.ParseQueryString(ub.Query); query["api-version"] = "1.5"; ub.Query = query.ToString(); requestMessage.RequestUri = ub.Uri; return Task.FromResult(0); }));

MIchaelMainer commented 7 years ago

@tjaisson Thank you for this post. I haven't seen someone use the .Net Graph client library to target the Azure AD directly. I'm fairly sure this is not a supported scenario for this client library.