Created
August 23, 2022 00:57
-
-
Save jeremysimmons/607f9b89fa2e4611872aa4f33cdefd89 to your computer and use it in GitHub Desktop.
HttpClient MultipartFormDataContent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| HttpClient httpClient = new HttpClient(); | |
| MultipartFormDataContent form = new MultipartFormDataContent(); | |
| form.Add(new StringContent(username), "username"); | |
| form.Add(new StringContent(useremail), "email"); | |
| form.Add(new StringContent(password), "password"); | |
| form.Add(new ByteArrayContent(file_bytes, 0, file_bytes.Length), "profile_pic", "hello1.jpg"); | |
| HttpResponseMessage response = await httpClient.PostAsync("PostUrl", form); | |
| response.EnsureSuccessStatusCode(); | |
| httpClient.Dispose(); | |
| string sd = response.Content.ReadAsStringAsync().Result; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment