Created
March 19, 2017 02:53
-
-
Save davidobrien1985/6b925773bb444fbdaf081f57c196b61e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Net; | |
using Newtonsoft.Json.Linq; | |
public class LicensingHelper | |
{ | |
public static JArray GetO365Skus(double apiVersion, string apiToken) | |
{ | |
var uri = $"https://graph.windows.net/myorganization/subscribedSkus?api-version={apiVersion}"; | |
WebRequest request = WebRequest.Create(uri); | |
request.Method = "GET"; | |
request.Headers.Add("Authorization", apiToken); | |
string responseContent = null; | |
using (WebResponse response = request.GetResponse()) | |
{ | |
using (Stream stream = response.GetResponseStream()) | |
{ | |
if (stream != null) | |
using (StreamReader sr99 = new StreamReader(stream)) | |
{ | |
responseContent = sr99.ReadToEnd(); | |
} | |
} | |
} | |
JObject jObject = JObject.Parse(responseContent); | |
return (JArray)jObject["value"]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment