I have a .NET core Web Api with this model:
public class UserForRegisterDto
{
[Required]
public string UserName { get; set; }
[Required]
public string Name { get; set; }
[Required]
public string LastName { get; set; }
[Required]
public string Password { get; set; }
[Required]
public string PhoneNumber { get; set; }
[Required]
public string MobilePhone { get; set; }
[Required]
public IFormFile Photo { get; set; }
}
On the other side I have a windows forms application using .NET 4 and I try to send data to the api using this class and piece of code:
public class UserForRegisterDto
{
public string UserName { get; set; }
public string Name { get; set; }
public string LastName { get; set; }
public string Password { get; set; }
public string PhoneNumber { get; set; }
public string MobilePhone { get; set; }
public byte[] Photo { get; set; }
}
and the piece of code to send this data is:
List<UserForRegisterDto> registrationList = Mapper.Map<List<UserForRegisterDto>>(usersList);
AuthenticatedHttpClientHandler clientHandler = new AuthenticatedHttpClientHandler(user.Id, Uow, _refreshTokenService);
clientHandler.UseDefaultCredentials = true;
HttpClient client = new HttpClient(clientHandler);
client.BaseAddress = new Uri(ConfigurationManager.AppSettings["appUrl"].ToString());
StringContent content = new StringContent(JsonConvert.SerializeObject(registrationList), Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync($"api/users/{user.Id}/users/PostGasStationUsers/{ConfigurationManager.AppSettings["appId"].ToString()}", content);
I need to use another data type instead of byte array which can be mapped to IFormFile data and how to do that.