Skip to content

Instantly share code, notes, and snippets.

@davidobrien1985
Created March 19, 2017 02:53
Show Gist options
  • Save davidobrien1985/6b925773bb444fbdaf081f57c196b61e to your computer and use it in GitHub Desktop.
Save davidobrien1985/6b925773bb444fbdaf081f57c196b61e to your computer and use it in GitHub Desktop.
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