Hello i'm getting a 400 bad request when trying to access an endpoint. Im using spring mvc and mapped my url to my page but failing to access the endpoint when using window.location.href. Please what did i do wrong
Below is my code:
$.ajax({
            type: 'post',
            url: 'guest/search',
            data: JSON.stringify(formData),
            contentType: 'application/json',
            success: function(dataRecieved){
                var dataRecieved= $.trim(dataRecieved);
                //console.log(dataRecieved);
                if(dataRecieved === 'true'){
                    $("#statusPlaceholder").html("Great rooms are available");
                    window.location.href="/guestReservation"; //fails to go to the endpoint
                }else{
                    $("#statusPlaceholder").html("Sorry. Rooms are not available. Please try again").show().fadeOut(3000).css("color","red");
                }
            }
        });
My mapped endPoint:
@RequestMapping(value = "/guestReservation", method = RequestMethod.GET)
    public
    @ResponseBody
    String createGuest(@RequestBody Occupancy occupancy){
        return "guestReservation";
    }
This is my Occupancy class:
@Entity
@Table(name="Occupancy")
public class Occupancy implements Serializable {
    private static final long serialVersionUID = 15L;
    public Occupancy() {
    }
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name="OCCUPANCYID", nullable = false)
    private long occupancyID;
    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="itinaryID")
    private Itinary itinary;
    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "roomNumber", referencedColumnName = "roomID")
    private Room room;
    @Column(name="roomsWanted")
    private int roomsWanted;
    public int getRoomsWanted() {
        return roomsWanted;
    }
    public void setRoomsWanted(int roomsWanted) {
        this.roomsWanted = roomsWanted;
    }
    //    @Column(name="status", columnDefinition = "default 0")
    private int status; // 0:reserved 1:cheched-in 2:checked-out
    private Date checkInDate;
    private Date checkOutDate;
    public int getStatus() {
        return status;
    }
    public void setStatus(int status) {
        this.status = status;
    }
    public long getOccupancyID() {
        return occupancyID;
    }
    public Itinary getItinary() {
        return itinary;
    }
    public void setItinary(Itinary itinary) {
        this.itinary = itinary;
    }
    public Room getRoom() {
        return room;
    }
    public void setRoom(Room room) {
        this.room = room;
    }
//    public int getNunOfPerson() {
//        return NunOfPerson;
//    }
//
//    public void setNunOfPerson(int nunOfPerson) {
//        NunOfPerson = nunOfPerson;
//    }
    public Date getCheckInDate() {
        return checkInDate;
    }
    public void setCheckInDate(Date checkInDate) {
        this.checkInDate = checkInDate;
    }
    public Date getCheckOutDate() {
        return checkOutDate;
    }
    public void setCheckOutDate(Date checkOutDate) {
        this.checkOutDate = checkOutDate;
    }
}
 
    