I need to code a method in a WebAPI application where I need to send an Image, this is what I'm doing:
public IHttpActionResult PostPicture(string xmit, int contactNum, [FromBody] byte[] picture) { Image img = null; using (var ms = new MemoryStream(picture)) { img = Image.FromStream(ms); } if (img != null) { return Ok(); } else { return BadRequest(); } } The problem is that when I'm sending the byte[] into the body in the request the value of the picture parameter is always null. I'm using Postman to test the method and the request body is being send as a x-www-form-urlencoded.
Could anyone help me to find what I'm doing wrong?
imageStream = await Request.Content.ReadAsStreamAsync()