title: .net core Web API - 415 Unsupported Media Type
body: <p>I'm building a .net core WebApi while following a course. I'm trying to upload photos, but I keep getting the error </p>
  
  <blockquote>
    <p>415 - Unsupported file type</p>
  </blockquote>
  
  <p>Here is the relevant controller</p>
  
  <pre class="lang-cs prettyprint-override"><code>[HttpPost]
  public async Task&lt;IActionResult&gt; AddPhotoForUser(int userId, [FromForm] PhotoForCreationDto photoForCreationDTO)
  {
      if(userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
          return Unauthorized();
  
      var userFromRepo = await _repo.GetUser(userId);
  
      var file = photoForCreationDTO.File;
  
      var uploadResult = new ImageUploadResult();
  
      if(file.Length &gt; 0)
      {
          using(var stream = file.OpenReadStream())
          {
              var uploadParams = new ImageUploadParams()
              {
                  File = new FileDescription(file.Name, stream),
                  Transformation = new Transformation().Width(500).Height(500).Crop("fill").Gravity("face")
              };
  
              uploadResult = _cloudinary.Upload(uploadParams);
          }
      }
  
      photoForCreationDTO.Url = uploadResult.Uri.ToString();
      photoForCreationDTO.PublicId = uploadResult.PublicId;
  
      var photo =_mapper.Map&lt;Photo&gt;(photoForCreationDTO);
  
      if(!userFromRepo.Photos.Any(u =&gt; u.IsMain))
          photo.IsMain = true;
  
      userFromRepo.Photos.Add(photo);
  
      if(await _repo.SaveAll())
      {
          var photoToReturn = _mapper.Map&lt;PhotoForReturnDto&gt;(photo);
          return CreatedAtRoute("GetPhoto", new { id = photo.Id}, photoToReturn);
      }
  
      return BadRequest("Could not add the photo");
  }   
  </code></pre>
  
  <p>I have no idea what the error is? Any ideas?</p>
  
  <p><a href="https://i.stack.imgur.com/ourXG.png" rel="nofollow noreferrer">Response and Request Headers</a></p>