//create POST request to submit a single TI Indicator
        public async Task <string> CreateTIIndicator(TiIndicator tiIndicator)
        {
            var token = await GetToken();

            string url = string.Format("https://graph.microsoft.com/beta/security/tiIndicators");

            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, url);

            request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);

            var stringTIIndicator = JsonConvert.SerializeObject(tiIndicator);

            request.Content = new StringContent(stringTIIndicator, Encoding.UTF8, "application/json");

            HttpClient http = new HttpClient();

            var response = await http.SendAsync(request);

            if (!response.IsSuccessStatusCode)
            {
                string error = await response.Content.ReadAsStringAsync();

                object formatted = JsonConvert.DeserializeObject(error);
                throw new WebException("Error Calling the Graph API: \n" + JsonConvert.SerializeObject(formatted, Formatting.Indented));
            }

            string json = await response.Content.ReadAsStringAsync();

            return(json);
        }
        //create PATCH request to update a single TI Indicator by Id
        public async Task <string> UpdateTIIndicator(string id, TiIndicator tIIndicator)
        {
            var token = await GetToken();

            string url = string.Format("https://graph.microsoft.com/beta/security/tiIndicators/" + id);

            //targetProduct & expirationDateTime are required by the API for patching TIs,
            //so first we need to make a call to GET the TI.
            var oldTI = await GetTIIndicator(id);

            //convert oldTI to Json object
            var tiJson = JsonConvert.DeserializeObject <TiIndicator>(oldTI);

            //then add vendorInformation to the PATCH body
            tIIndicator.TargetProduct      = tiJson.TargetProduct;
            tIIndicator.ExpirationDateTime = tiJson.ExpirationDateTime;

            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Patch, url);

            request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);

            var stringTIIndicator = JsonConvert.SerializeObject(tIIndicator);

            request.Content = new StringContent(stringTIIndicator, Encoding.UTF8, "application/json");

            HttpClient http = new HttpClient();

            var response = await http.SendAsync(request);

            if (!response.IsSuccessStatusCode)
            {
                string error = await response.Content.ReadAsStringAsync();

                object formatted = JsonConvert.DeserializeObject(error);
                throw new WebException("Error Calling the Graph API: \n" + JsonConvert.SerializeObject(formatted, Formatting.Indented));
            }

            string json = await response.Content.ReadAsStringAsync();

            return(json);
        }