Вы находитесь на странице: 1из 3

//Información de Token

private NotificacionCorreoRetiro ObtenerClavesSlot1(NotificacionCorreoRetiro Notificacion,


string ReferenciaSticker)

object resultad = new object();

CodigosRetiroSlot resultado = new CodigosRetiroSlot();

try

using (HttpClient client = new HttpClient())

client.DefaultRequestHeaders.Accept.Clear();

client.DefaultRequestHeaders.Accept.Add(new
MediaTypeWithQualityHeaderValue("application/json"));

client.BaseAddress = new
Uri("http://hc.espaciosdigitales.co/api/v1/infoRequest/codeListByRef?reference=1001");

//new
Uri("http://hc.espaciosdigitales.co/api/v1/infoRequest/codeListByRef?reference=000");

//new
Uri("http://hc.espaciosdigitales.co/api/v1/infoRequest/slotList?state=3&storeId=1");

//new Uri(string.Format("{0}reference={1}",
ConfigurationManager.AppSettings.Get("EDServicioCodigoAperturaCliente"), Sticker));

string json = @"{{ ""userName"" : ""{0}"", ""password"": ""{1}"" }}";

json = string.Format(json, "SGLP01", "%7sdm@mRApAJ");

var content = new StringContent(json, Encoding.UTF8, "application/json");

HttpClient clientHeader = new HttpClient();

clientHeader.DefaultRequestHeaders.Accept.Clear();
clientHeader.DefaultRequestHeaders.Accept.Add(new
MediaTypeWithQualityHeaderValue("application/json"));

clientHeader.BaseAddress = new
Uri("http://10.23.14.95:8995/Servicios/Autenticacion_JWT/api/authentication/login");

HttpResponseMessage resultHeader = clientHeader.PostAsync("", content).Result;

string token = "";

if (resultHeader.IsSuccessStatusCode)

var resultJsonHead = resultHeader.Content.ReadAsStringAsync().Result;

token = resultJsonHead.ToString();

client.DefaultRequestHeaders.Add("token", token);

HttpResponseMessage result = client.GetAsync("").Result;

if (result.IsSuccessStatusCode)

var resultJson = result.Content.ReadAsStringAsync().Result;

resultado.Vector = result.Headers.GetValues("auth_vector").First().ToString();

resultado = JsonConvert.DeserializeObject<CodigosRetiroSlot>(resultJson);

resultad = resultado;

else

var resultJson = result.Content.ReadAsStringAsync().Result;

dynamic contentResult = JsonConvert.DeserializeObject<dynamic>(resultJson);

resultad = contentResult;

}
return Notificacion;

catch (Exception ex)

Logger.ErrorRegister(ex);

throw new Exception(ex.Message);

Вам также может понравиться