0

I want to send an Object between apis but my controller is waiting for this

 public async Task<IActionResult> Post([FromForm]UserViewModel input, CancellationToken ct = default(CancellationToken))

How can I send that model as a FromForm?

My Current call:

 var userContent = JsonConvert.SerializeObject(userRequest);
            HttpRequestMessage request = new HttpRequestMessage
            {
                Method = HttpMethod.Post,
                RequestUri = new Uri($"{_apiUrl}users"),
                Content = new StringContent(userContent, Encoding.UTF8, "application/json")
            };

            var result = await _httpClient.SendAsync(request);

My model:

public class UserViewModel
{
 public string name;
 public string lastname;
 public List<IFormFile> GalleryImages { get; set; }

}
Silver Qui.
  • 49
  • 2
  • 8
  • 1
    Refer to this [link](https://stackoverflow.com/questions/58645233/call-a-multi-part-form-method-programmatically/58655025#58655025) to post Multi-Part Form using `httpClient` and this [link](https://stackoverflow.com/a/36433458/10158551) to convert your IFormFile to byte[] – Ryan Apr 03 '20 at 09:47
  • You're right !! thanks! – Silver Qui. Apr 03 '20 at 17:03

0 Answers0