[Solved] how to post string to URL in UWP


You can upload a file with the HttpClient (which replaces the WebClient in UWP)

Code:

private async Task<string> UploadImage(byte[] file, Uri url)
{
    using (var client = new HttpClient())
    {
        MultipartFormDataContent form = new MultipartFormDataContent();
        var content = new StreamContent(new MemoryStream(file));
        form.Add(content, "postname", "filename.jpg");
        var response = await client.PostAsync(url, form);
        return await response.Content.ReadAsStringAsync();
    }
}

0

solved how to post string to URL in UWP