Ejemplo n.º 1
0
        static void ObterTokenAsync()
        {
            headers.Clear();
            parameters.Clear();

            parameters.Add(new KeyValuePair <string, string>("DDI", "55"));
            parameters.Add(new KeyValuePair <string, string>("Telefone", "14991912061"));
            parameters.Add(new KeyValuePair <string, string>("CodigoAtivacao", "39414")); //Homolog
            //parameters.Add(new KeyValuePair<string, string>("CodigoAtivacao", "29803")); //Local

            var ret = ExecutarApi.ExecutarApiJSON <RetornoApi>(Metodo.GET, null, headers, parameters, apiURLWS, "Account/Token");

            headers.Add(new KeyValuePair <string, string>("Authorization", $"Bearer {ret.Data.Entidade.token}"));
        }
Ejemplo n.º 2
0
        static void CallApi(ParceiroViewModel.ParceiroSaveViewModel parceiro)
        {
            result = ExecutarApi.ExecutarApiJSON <object>(Metodo.POST, parceiro, headers, parameters, apiURLWS, "Parceiro");

            if (result.Status == 200)
            {
                Console.WriteLine($"{parceiro.Nome} - {contador++} - ({DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss")})");
            }

            else if (result.Status == 401)
            {
                ObterTokenAsync();
                CallApi(parceiro);
            }
        }