How do you accept a byte[] in WebAPI controller in .net core. Something like below:
[HttpPost]
public IActionResult Post(byte[] rawData)
{
try
{
System.Diagnostics.Trace.WriteLine("Total bytes posted: " + rawData?.Length);
return StatusCode(200);
}
catch(Exception ex)
{
return StatusCode(500, $"Error. msg: {ex.Message}");
}
}
I get 415 Unsupported Media Type error when testing from fiddler. Is this even possible in .net core webapi? I have searched for a while and there are no solutions for .net core. There are examples of BinaryMediaTypeFormatter which would not work with .net core webapi. If this is not possible with webapi then what is the best solution to accept a byte array in .net core web applications?
Our old application is an asp.net forms app. It will call Request.BinaryRead() to get the byte array and process the data. We are in the process of migrating this application to .net core.
Thank you.