title: Building a Spring Controller for a multipart/mixed post by Syncfusion Datamanager
body: <p><strong>Hello, I am currently trying to build a spring boot backend to match with Syncfusion's Datamanager (their documentation for backend construction is purely for .NET as far as I can see.)  I have managed to get the GET functionality working so my data type mapping is correct but posting is causing some issues.  Specifically, it appears that DataManager posts a multipart/mixed that includes the JSON object i'm trying to persist as well as some sort of batch file (which I don't care about).  Since I can't modify datamanager, I need to figure out a way in spring to purely pull out the JSON.  I'm sure it's really simple but I'm fairly new to this and couldn't find any other previously asked questions that matched my current situation.
  Here is a copy of the Request details as listed in Chrome Developer tools.</strong></p>
  
  <p><strong>General</strong></p>
  
  <p>***Request URL: <a href="http://localhost:8082/schedule/" rel="nofollow noreferrer">http://localhost:8082/schedule/</a>$batch</p>
  
  <p>Request Method: POST</p>
  
  <p>Status Code: 415 </p>
  
  <p>Remote Address: [::1]:8082</p>
  
  <p>Referrer Policy: no-referrer-when-downgrade</p>
  
  <p><strong>Response Headers</strong></p>
  
  <p>Access-Control-Allow-Headers: Authorization, Content-Type</p>
  
  <p>Access-Control-Allow-Methods: POST, PUT, GET, OPTIONS, DELETE</p>
  
  <p>Access-Control-Allow-Origin: *</p>
  
  <p>Access-Control-Max-Age: 3600</p>
  
  <p>Content-Type: application/json</p>
  
  <p>Date: Fri, 22 Nov 2019 14:38:39 GMT</p>
  
  <p>Transfer-Encoding: chunked</p>
  
  <p>Vary: Origin</p>
  
  <p>Vary: Access-Control-Request-Method</p>
  
  <p>Vary: Access-Control-Request-Headers</p>
  
  <p><strong>Request Headers</strong></p>
  
  <p>Accept: application/json, text/javascript, <em>/</em>; q=0.01, application/json</p>
  
  <p>Accept-Encoding: gzip, deflate, br</p>
  
  <p>Accept-Language: en-US,en;q=0.9</p>
  
  <p>Connection: keep-alive</p>
  
  <p>Content-Length: 358</p>
  
  <p>Content-Type: multipart/mixed; boundary=batch_dddabc0b-930c-47fc-b7e5-934999f0adc9</p>
  
  <p>Host: localhost:8082</p>
  
  <p>Origin: <a href="http://localhost:4200" rel="nofollow noreferrer">http://localhost:4200</a></p>
  
  <p>Referer: <a href="http://localhost:4200/main/schedule" rel="nofollow noreferrer">http://localhost:4200/main/schedule</a></p>
  
  <p>Sec-Fetch-Mode: cors</p>
  
  <p>Sec-Fetch-Site: same-site</p>
  
  <p>User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36</p>
  
  <p><strong>Request Payload</strong></p>
  
  <p>--batch_dddabc0b-930c-47fc-b7e5-934999f0adc9</p>
  
  <p>Content-Type: application/http; msgtype=request</p>
  
  <p>POST /api/null HTTP/1.1</p>
  
  <p>Content-Type: application/json; charset=utf-8</p>
  
  <p>Host: localhost:4200</p>
  
  <p>{"Subject":"m","Id":4,"StartTime":"2019-11-21T06:30:00.000Z","EndTime":"2019-11-21T07:00:00.000Z","IsAllDay":false}</p>
  
  <p>--batch_dddabc0b-930c-47fc-b7e5-934999f0adc9--***</p>
  
  <p><strong>And here is a copy of my Controller as it currently stands.  (Basically was built to accept regular application/json POSTS)</strong></p>
  
  <pre><code>import java.util.List;
  
  import javax.servlet.http.HttpServletResponse;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.web.bind.annotation.CrossOrigin;
  import org.springframework.web.bind.annotation.GetMapping;
  import org.springframework.web.bind.annotation.PostMapping;
  import org.springframework.web.bind.annotation.RequestBody;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RestController;
  
  import com.quietmodebackend.models.Appointment;
  import com.quietmodebackend.repos.ScheduleRepository;
  
  @CrossOrigin
  @RestController
  @RequestMapping("/schedule")
  public class ScheduleController {
  
      @Autowired
      ScheduleRepository myRepo;
  
      @GetMapping
      public List&lt;Appointment&gt; getAppointments(HttpServletResponse response){
  
          response.setStatus(200);
          return myRepo.findAll();
      }
  
      @PostMapping("/$batch")
      public Appointment postAppointments(HttpServletResponse response, @RequestBody Appointment appointment){
          return myRepo.save(appointment);
      }
  
  
  }
  </code></pre>
  
  <p>Any help would be greatly appreciated.</p>