Ejemplo n.º 1
0
        internal static async Task <string> PutEntities(string urlLink, string content)
        {
            HttpClient          client   = HttpConnection.CreateClient(await Logic.GetToken());
            HttpResponseMessage response = await client.PutAsync(urlLink, new StringContent(content, Encoding.UTF8, Constants.ContentTypeHeaderJson)).ConfigureAwait(false);

            return(await response.Content.ReadAsStringAsync());
        }
Ejemplo n.º 2
0
        internal static async Task <string> DeleteEntities(string urlLink)
        {
            HttpClient client = HttpConnection.CreateClient(await Logic.GetToken());
            Task <HttpResponseMessage> response = client.DeleteAsync(urlLink);

            return(await response.Result.Content.ReadAsStringAsync().ConfigureAwait(false));
        }
Ejemplo n.º 3
0
        internal static async Task <string> PostImageStream(byte[] input)
        {
            try
            {
                Stream stream = new MemoryStream(input);
                using (HttpClient client = new HttpClient())
                {
                    client.BaseAddress = new Uri(Constants.BaseURL);
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(Constants.AuthorizationHeaderType, await Logic.GetToken());
                    StreamContent       inputData = new StreamContent(stream);
                    string              urlLink   = "chat/postimage";
                    HttpResponseMessage response  = await client.PostAsync(urlLink, inputData).ConfigureAwait(false);

                    var result = await response.Content.ReadAsStringAsync();

                    return(result);
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex, Logic.GetErrorProperties(ex));
                return(string.Empty);
            }
        }