public static async Task <string> CmdAddCounter(TSCounter ParTSCounter) { try { if (ParTSCounter.Source.Contains("localhost")) { return("OK"); } ParTSCounter.Source = ParTSCounter.Source.Replace("https://lupblazordemos.z13.web.core.windows.net/", null); ParTSCounter.Source = ParTSCounter.Source.Replace("https://khutsuri.z1.web.core.windows.net/", "khutsuri"); ParTSCounter.Source = ParTSCounter.Source.Replace("https://khutsuridev.z20.web.core.windows.net/", "khutsuridev"); ParTSCounter.Source = ParTSCounter.Source.Replace("Page", null); ParTSCounter.Source = ParTSCounter.Source.Replace("page", null); int k = ParTSCounter.Source.IndexOf("?"); if (k > -1) { ParTSCounter.Source = ParTSCounter.Source.Substring(0, k); } if (string.IsNullOrEmpty(ParTSCounter.Source)) { ParTSCounter.Source = "Home"; } CmdTrimEntity(ParTSCounter); TSCounter tsCounterForSend = CopyObject <TSCounter>(ParTSCounter); httpClient2.DefaultRequestHeaders.Accept.Clear(); httpClient2.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); httpClient2.DefaultRequestHeaders.Remove("x-functions-key"); httpClient2.DefaultRequestHeaders.Add("x-functions-key", "WimOOGUL0pnXXHVVw1cMRQF5NCxdnOpjVa5eQpTa8b5s5a3ar94rNA=="); HttpResponseMessage response = await httpClient2.PostAsJsonAsync("Counter/add", tsCounterForSend); string result = await response.Content.ReadFromJsonAsync <string>(); httpClient2.DefaultRequestHeaders.Remove("x-functions-key"); httpClient2.DefaultRequestHeaders.Accept.Clear(); return(result); } catch (Exception ex) { PrintError(ex.Message, MethodBase.GetCurrentMethod()); return(ex.Message); } }
public static async Task <string> CmdAddCounter(TSCounter ParTSCounter) { try { if (ParTSCounter.Source.Contains("localhost")) { return("OK"); } httpClient2.DefaultRequestHeaders.Accept.Clear(); httpClient2.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); ParTSCounter.Source = ParTSCounter.Source.Replace("https://", null); ParTSCounter.Source = ParTSCounter.Source.Replace("http://", null); CmdTrimEntity(ParTSCounter); TSCounter tsCounterForSend = CopyObject <TSCounter>(ParTSCounter); httpClient2.DefaultRequestHeaders.Add("x-functions-key", "20bLI4NLXhjZ77Ud5XDiEM9UlDUCkSSAUgXZ53n6/NkcG3vWpXmUvA=="); HttpResponseMessage response = await httpClient2.PostAsJsonAsync("Counter/add", tsCounterForSend); string result = await response.Content.ReadFromJsonAsync <string>(); httpClient2.DefaultRequestHeaders.Remove("x-functions-key"); httpClient2.DefaultRequestHeaders.Accept.Clear(); return(result); } catch (Exception ex) { Console.WriteLine(ex.Message); return(ex.Message); } }