title: Why does my post not load the photos when creating?
body: <p>I created an app with some posts about charity. I made a POST method for creating new posts. This posts contain a title, some text and some photos. However, when I am creating the post, the frontend will show everything except for the photos I've loaded(using cloudinary), with no errors in the console. When I am trying to test my create post method in Postman I receive a 415-Unsupported Media Type error and I have not been able to figure the problem out for some days now. I am loading the photos as form-data in Postman.
  This is my photo service:</p>
  <pre><code> public class PhotoService : IPhotoService
      {
          private readonly Cloudinary _cloudinary;
          public PhotoService(IOptions&lt;CloudinarySettings&gt; config)
          {
              var acc = new Account
                  (
                      config.Value.CloudName,
                      config.Value.ApiKey,
                      config.Value.ApiSecret
                  );
              _cloudinary = new Cloudinary(acc);
          }
  
          public async Task&lt;ImageUploadResult&gt; AddPhotoAsync(IFormFile file)
          {
              var uploadResult = new ImageUploadResult();
              
              if(file.Length &gt; 0)
              {
                  using var stream = file.OpenReadStream();
  
                  
                  var uploadParams = new ImageUploadParams
                  {
                      File = new FileDescription(file.FileName, stream),
                      Transformation = new Transformation().Height(500).Width(500).Crop(&quot;fill&quot;)
                  };
  
                  uploadResult = await _cloudinary.UploadAsync(uploadParams);
              }
              return uploadResult;
          }
  </code></pre>
  <p>This is my create post method:</p>
  <pre><code>[HttpPost(&quot;create&quot;)]
          public async Task&lt;ActionResult&lt;PostDto&gt;&gt; CreatePost(PostDto postDto)
          {
              if (!ModelState.IsValid) return BadRequest(&quot;Not a valid model&quot;);
              var user = await _userRepository.GetUserByUsernameAsync(User.GetUsername());
  
              var post = new Post
              {
                  Title = postDto.Title,
                  Text = postDto.Text,
                  UserId = user.Id,
                  Photos = postDto?.Photos
              };
  
              _context.Posts.Add(post);
  
              await _context.SaveChangesAsync();
  
              return new PostDto
              {
                  Title = post.Title,
                  Text = post.Text,
                  UserId = post.UserId,
                  Photos = post?.Photos
              };
          }
  </code></pre>
  <p>And this is my method to add a photo in my PostController:</p>
  <pre><code> [HttpPost(&quot;add-photo&quot;)]
          public async Task&lt;ActionResult&lt;PhotoDto&gt;&gt; AddPhoto(IFormFile file, int id)
          {
              var post = await _postRepository.GetPostByIdAsync(id);
              var result = await _photoService.AddPhotoAsync(file);
  
              if (result.Error != null) return BadRequest(result.Error.Message);
  
              var photo = new Photo
              {
                  Url = result.SecureUrl.AbsoluteUri,
                  PublicId = result.PublicId
              };
  
              post.Photos.Add(photo);
  
              if (await _postRepository.SaveAllAsync())
              {
                  return CreatedAtRoute(&quot;GetPost&quot;, new { id = post.Id }, _mapper.Map&lt;PhotoDto&gt;(photo)); ;
              }
  
              return BadRequest(&quot;Problem adding photo&quot;);
          }
  </code></pre>
  <p>What is wrong with my code? I've done some research, but I have not been able to detect the problem.
  Thank you!</p>