@daotin, you can try like this if you want to upload byte array in the form of base64string without using multipart,
private void Upload()
{
string contents = Convert.ToBase64String(data);// here data is byte[] of your image
UploadAttachment(contents);
}
public async Task<Tuple<bool, string>> UploadAttachment(string payload)
{
bool isSuccess = false;
string message = string.Empty;
Uri uri = new Uri(API_URL);
try
{
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
var response = string.Empty;
using (HttpClient client = new HttpClient())
{
HttpResponseMessage result = null;
result = await client.PostAsync(uri, content);
if (result.IsSuccessStatusCode)
isSuccess = true;
else
{
var error = await result.Content.ReadAsStringAsync();
var errorResponse = JsonConvert.DeserializeObject<ErrorResponse>(error);
message = errorResponse?.Errors?.FirstOrDefault();
}
}
}
catch (Exception ex)
{
message = ex.Message;
}
return new Tuple<bool, string>(isSuccess, message);
}