public static void webAcknowledgement(String log_ids) { if (log_ids != "") { log_ids = log_ids.Substring(0, (log_ids.Length - 1)); DepartmentSettings.getData(); String API = "http://159.89.170.58/api/v1"; string URL = API + "" + "/activities/remove"; string urlParameters = "?department_id=" + DepartmentSettings.DepartmentId + "&activity_ids=" + log_ids; HttpClient client = new HttpClient(); client.BaseAddress = new Uri(URL); Console.WriteLine("API URL: " + URL + urlParameters); // Add an Accept header for JSON format. client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); // List data response. try { HttpResponseMessage response = client.DeleteAsync(urlParameters).Result; // Blocking call! } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message.ToString()); } } }
public static HttpResponseMessage getRequest(String action_url, String model) { DepartmentSettings.getData(); string URL = API + "" + action_url; string urlParameters = "?department_id=" + DepartmentSettings.DepartmentId; HttpClient client = new HttpClient(); client.BaseAddress = new Uri(URL); Console.WriteLine("API URL: " + URL + urlParameters); // Add an Accept header for JSON format. client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); // List data response. try { HttpResponseMessage response = client.GetAsync(urlParameters).Result; // Blocking call! return(response); } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message.ToString()); return(client.GetAsync(urlParameters).Result); } }