How to accept file in binary format in asp.net core web api

Andrej 221 Reputation points
2021-12-01T12:03:56.12+00:00

How to accept file in binary format in asp.net core web api controller and processed it. I have request see image below
154116-image.png

and i try to accept it in my controller but it doesn't work

        [HttpPost("catalist")]  
        public async Task<IActionResult> UploadFromCatalistAsync([FromBody] byte[] binaryFile, CancellationToken token)  
        {  
            //process binaryFile  
            return Ok();  
        }  
  

but I get error 415 Unsupported Media Type, could please help me what changes I need to make in my API to accept the file in this type?

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,194 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,286 questions
0 comments No comments
{count} votes

0 additional answers

Sort by: Most helpful