1

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; }

}
2
  • 1
    Refer to this link to post Multi-Part Form using httpClient and this link to convert your IFormFile to byte[] Commented Apr 3, 2020 at 9:47
  • You're right !! thanks! Commented Apr 3, 2020 at 17:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.