title: Pass List of objects from angular to spring
body: <p>I want to pass a List of objects from angular to spring with rest api but i could not match the array that i'm passing to the service in angular with the one that i'm passing to the controller in Spring and i'm getting this error :</p>
  
  <pre><code>ERROR Invalid JSON input: Cannot deserialize instance of `com.backend.guestnhouse.payload.request.RoomRequest` out of START_ARRAY token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `com.backend.guestnhouse.payload.request.RoomRequest` out of START_ARRAY token
       at [Source: (PushbackInputStream); line: 1, column: 1]
  </code></pre>
  
  <p>I have this method where i'm passing a List of objects to @RequestBody : </p>
  
  <pre><code>@PostMapping
  public String addRoom(@RequestBody RoomRequest roomRequest) {
      return roomService.addRooms(roomRequest);
  }
  </code></pre>
  
  <p>This is the body that i want to pass to the method </p>
  
  <pre><code>    {
       "rooms":[
                {
                "startdate":"2020-04-25",
                "enddate":"2020-04-29",
                "roomName":"room 1",
                },
                {
                "startdate":"2020-04-25",
                "enddate":"2020-04-29",
                "roomName":"room 2",
                }
              ]
      }
  </code></pre>
  
  <p>This is my method in component.ts</p>
  
  <pre><code>addRoomstobebooked(rooms:any){
      this.roomsService.addRooms(rooms).subscribe(
          data=&gt; {
              this.message=data
              console.log(this.message)
          })
    }
  </code></pre>
  
  <p>This is my service</p>
  
  <pre><code>addRooms(rooms::any ): Observable&lt;any&gt; {
  return this.http.post(`${API_URL}`,rooms);
   }
  </code></pre>
  
  <p>This is the array that i have in angular that i'm passing to the service</p>
  
  <pre><code>[ 0: {
      "startdate":"2020-04-25",
      "enddate":"2020-04-29",
      "roomName":"room 1",
      },
  1: {
      "startdate":"2020-04-25",
       "enddate":"2020-04-29",
       "roomName":"room 2",
      },
   ]
  </code></pre>
  
  <p>How to match the List that i have in Angular with the one that i want to pass to the method in Spring?</p>
  
  <p>Thank you</p>