Skip to content

Instantly share code, notes, and snippets.

@jatovar
Last active October 9, 2017 14:52
Show Gist options
  • Save jatovar/6b4e53d883fb13c0c22f44fb18653cd1 to your computer and use it in GitHub Desktop.
Save jatovar/6b4e53d883fb13c0c22f44fb18653cd1 to your computer and use it in GitHub Desktop.
Bug
public async Task<string> GetKey()
{
if (!IsConnected())
throw new NotConnectedException();
try
{
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(MediaType));
HttpContent content = new StringContent(string.Empty, Encoding.UTF8, MediaType);
var response = await client.PostAsync(LibroAzulWebService.LoginAddress, content);
string body = await response.Content.ReadAsStringAsync();
var dto = JsonConvert.DeserializeObject<LibroAzul>(body);
if (dto.Success)
{
Key = dto.Token;
return Key;
}
throw new Exception(
"Error en el backend al logear al libro azul" +
"\n Respuesta: " + JsonConvert.SerializeObject(dto) +
"\n HTTP Status: " + response.StatusCode);
}
}
catch (Exception e)
{
throw e;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment