0

I don't see anywhere a simple example regarding how to get a file from an API user via web api. here's my function signature ( modified for stackoverflow ) :

[HttpPost]
    [Route("api/Tasks/CreateTaskWithFileOption")]
    public TaskDetailsRequestModel CreateTaskWithFileOption(string token, int templateId, byte[] fileForSignature = null)

That i don't get values when trying to send a parameter to my service, what the right way to implement it ? ( put aside authorization , the only thing i need is to understand how to pass that byte array )

barak ben horin
  • 394
  • 1
  • 3
  • 12
  • https://stackoverflow.com/questions/32184360/post-byte-array-to-web-api-server-using-httpclient – CodeCaster Oct 16 '18 at 13:04
  • i don't see how can i send the data both and desalinize it ( both string , int & byte array ). – barak ben horin Oct 16 '18 at 13:30
  • You can have two ways: var httpRequest = System.Web.HttpContext.Current.Request; HttpFileCollection uploadFiles = httpRequest.Files; var provider = new MultipartMemoryStreamProvider(); await Request.Content.ReadAsMultipartAsync(provider); foreach (var file in provider.Contents) { var filename = file.Headers.ContentDisposition.FileName.Trim('\"'); Stream ste = await file.ReadAsStreamAsync(); } – saumil_ Oct 17 '18 at 07:16

0 Answers0