using System; using System.Collections.Generic; using System.Net.Http; using System.Threading.Tasks; public class MyClass { public async Task Geracao(object ReceberObjetoGeracaoArquivo) { var userPass = new Dictionary { { "alias", "BRA_M_STG" }, { "password", "XCufdude#" } }; var client = new HttpClient(); var responseAuth = await client.PostAsJsonAsync("https://logcorpsboot.aacc.pre.corp/login/authenticate", userPass); var cookieGeral = await responseAuth.Content.ReadAsAsync>(); var cookie = cookieGeral["cookie"]; var UniversalCookie = new Dictionary { { "Cookie", $"NewUniversalCookie={cookie}" } }; var responseFrontConfig = await client.GetAsync("https://monitorbw-stg.aacc.pre.corp/assets/config/frontconfig", UniversalCookie); var responseToken = await client.PostAsync("https://corporate-credentials-stg.aacc.pre.corp/token", null); var FrontConfig = await responseFrontConfig.Content.ReadAsAsync>(); var tokenGeral = await responseToken.Content.ReadAsAsync>(); var tokenFonte = tokenGeral["token"]; var SosVal = new Dictionary { { "client_id", FrontConfig["clientID"].ToString() }, { "client_secret", FrontConfig["clientSecret"].ToString() }, { "grant_type", FrontConfig["grant_type"].ToString() }, { "scope", FrontConfig["scope"].ToString() }, { "token", tokenFonte } }; var responseSos = await client.PostAsync("https://sos-intra-gtw-hq.aacc.pre.corp/oauth/token", new FormUrlEncodedContent(SosVal)); var Acess_Token = await responseSos.Content.ReadAsAsync>(); var Acess_Token2 = Acess_Token["access_token"]; var headersGeracaoArquivo = new Dictionary { { "Authorization", $"Bearer {Acess_Token2}" }, { "X-Ibm-Client-Id", FrontConfig["clientID"].ToString() }, { "Environment-Backend", ((List)FrontConfig["entorno"])[0].ToString() } }; var RequestGeracaoCSV = await client.PostAsJsonAsync("https://monitorbw-stg.aacc.pre.corp/api/trace/refresh-trace-table", ReceberObjetoGeracaoArquivo, headersGeracaoArquivo); return RequestGeracaoCSV; } }