public async Task <LoginResponse> LoginAsync(LoginRequest connexion) { try { if (!string.IsNullOrEmpty(UserProperties.GetApiKey()) && !client.DefaultRequestHeaders.Contains("X-Api-Key")) { client.DefaultRequestHeaders.Add("X-Api-Key", UserProperties.GetApiKey()); } var uri = new Uri(string.Format(Constants.BASE_URL + UserProperties.GetLocalIP() + Constants.API_LOGIN, string.Empty)); var json = JsonConvert.SerializeObject(connexion); var payload = new StringContent(json, Encoding.UTF8, "application/json"); var response = await client.PostAsync(uri, payload); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject <LoginResponse>(content); return(result); } } catch (Exception e) { Debug.WriteLine(e); } return(null); }
public OctoService() { client = new HttpClient(); //client.MaxResponseContentBufferSize = 256000; if (!string.IsNullOrEmpty(UserProperties.GetApiKey())) { client.DefaultRequestHeaders.Add("X-Api-Key", UserProperties.GetApiKey()); } }
public async override void ViewAppeared() { base.ViewAppeared(); if (!string.IsNullOrEmpty(UserProperties.GetLocalIP()) && !string.IsNullOrEmpty(UserProperties.GetApiKey())) { await _navigationService.Navigate <MainViewModel>(); } }