/// <summary> /// Create a Qualifier object /// </summary> /// <param name="name">Invariant Name to be indentified in Database for debug use</param> /// <param name="url">Url field for a Qualifier</param> /// <param name="values">The values.</param> /// <returns> /// Qualifier object. /// </returns> private static Qualifier CreateQualifier(string name, string url, List<string> values) { var qualifier = new Qualifier { Custom = true, Name = name, Url = url, Values = values }; return qualifier; }
/// <summary> /// Posts the qualifier to service. /// </summary> /// <param name="url">The URL.</param> /// <param name="qualifier">The qualifier.</param> /// <returns>HttpResponseMessage after post.</returns> /// <exception cref="System.ArgumentException">Invalid url</exception> /// <exception cref="System.Exception">Ingesting Attribute to service returns insuccess response</exception> private static HttpResponseMessage PostQualifierToService(string url, Qualifier qualifier) { if (!Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute)) { throw new ArgumentException("Invalid url"); } using (var client = new HttpClient()) { using (var request = new HttpRequestMessage(HttpMethod.Post, url)) { request.Content = new StringContent(JsonConvert.SerializeObject(qualifier), Encoding.UTF8, "application/json"); var response = client.SendAsync(request, CancellationToken.None).Result; if (!response.IsSuccessStatusCode) { throw new Exception( "Ingesting Attribute to service returns insuccess response"); } return response; } } }