[Getting error highlighted in yellow in eclipse while automating post API through rest assured]
package com.testautomation.apitesting;import org.json.simple.JSONObject;import org.testng.annotations.Test;import io.restassured.RestAssured;import io.restassured.http.ContentType;public class PostAPIRequest { @Test public void createBooking() { JSONObject booking= new JSONObject(); JSONObject bookingdates= new JSONObject(); booking.put("firstname","Garima"); booking.put("lastname", "Nandal"); booking.put("totalprice", "1000"); booking.put("depositpaid", "true"); booking.put("additionalneeds", "Breakfast"); booking.put("bookingdates", "bookingdates"); bookingdates.put("checkin", "2024-06-26"); bookingdates.put("checkout", "2024-06-27"); RestAssured .given() .contentType(ContentType.JSON) .body(booking.toString()) .baseUri("https://restful-booker.herokuapp.com/booking") .when() .post() .then() .assertThat() .statusCode(200); }}
Error message is showing in attached SS.
Can anyone help me please.
I tried passing values for post api using put method and expected that test case should get pass for creation of data. I was expecting 200 or 201 but getting 500 in console. Not sure, what's going wrong.
Error in yellow says:
Type safety: The method put(Object, Object) belongs to the raw typeHashMap. References to generic type HashMap<K,V> should beparameterized