/// <summary>
        /// register an extension attribute on the Application specified by StringConstants.AppObjectId
        /// this version only registers a string extension attribute on users
        /// </summary>
        /// <param name="strExtension">extension name</param>
        /// <param name="strErrors">error return value</param>
        /// <returns>success or failure</returns>
        public bool RegisterExtension(string strExtension, ref string strErrors)
        {
            // setup the extension definition
            ExtensionDefinition extension = new ExtensionDefinition();
            extension.name = strExtension;
            extension.dataType = "String";
            extension.targetObjects.Add("User");

            // Execute the POST to create new extension
            ExtensionDefinition returnedExtension = this.graphCall.createExtension(extension, ref strErrors);
            return returnedExtension != null;
        }
        public ExtensionDefinition createExtension(ExtensionDefinition extension, ref string strErrors)
        {
            if (this.aadAuthentication.AadAuthenticationResult.IsExpired() ||
                           this.aadAuthentication.AadAuthenticationResult.WillExpireIn(2))
                this.aadAuthentication.AadAuthenticationResult = this.aadAuthentication.GetNewAuthenticationResult(ref strErrors);

            if (this.aadAuthentication.AadAuthenticationResult == null)
                return null;

            string authnHeader = "Authorization: " + this.aadAuthentication.AadAuthenticationResult.AccessToken;

            string uri = this.BaseGraphUri + "/applications/" + StringConstants.AppObjectId + "/extensionProperties" + "?" + this.ApiVersion;

            JsonSerializerSettings jsonSettings = new JsonSerializerSettings();
            jsonSettings.NullValueHandling = NullValueHandling.Ignore;
            jsonSettings.DefaultValueHandling = DefaultValueHandling.Ignore;
            JsonSerializer serializer = JsonSerializer.CreateDefault(jsonSettings);
            string body = JsonConvert.SerializeObject(JObject.FromObject(extension, serializer), Formatting.None, jsonSettings);

            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
                System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();

                request.Headers.Add(authnHeader);
                request.Method = "POST";
                request.ContentType = "application/json";
                byte[] data = encoding.GetBytes(body);
                request.ContentLength = data.Length;
                using (Stream stream = request.GetRequestStream())
                {
                    stream.Write(data, 0, data.Length);
                }

                using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
                {
                    if (response.StatusCode != HttpStatusCode.Created)
                    {
                        throw new Exception(String.Format(
                        "Server error (HTTP {0}: {1}).",
                        response.StatusCode,
                        response.StatusDescription));
                    }
                    else
                        using (var stream = response.GetResponseStream())
                        {
                            string payload;
                            using (System.IO.StreamReader reader = new System.IO.StreamReader(stream))
                            {
                                payload = reader.ReadToEnd();
                            }

                            return JObject.Parse(payload).ToObject<ExtensionDefinition>();
                        }
                }
            }

            catch (WebException webException)
            {
                GraphHelperEventSourceLogger.Log(webException, ref strErrors);
                return null;
            }
        }