How to use post method in rest assured framework. i am learning API by using Rest Assured Framework can anyone help me how to use.
MY code Is:
RestAssured.baseURI ="https://reqres.in";
RequestSpecification request = RestAssured.given();
JSONObject requestParams = new JSONObject();
requestParams.put("email", "sydney@fife");
requestParams.put("password", "pistol444");
request.body(requestParams.toJSONString());
Response response = request.post("/api/register");
int statusCode = response.getStatusCode();
System.out.println("API response code is :" + statusCode);
String body =response.asString();
System.out.println("Response body is : "+ body);
Getting error message after consume this Post method:
API response code is :400 Response body is : {"error":"Missing email or username"}
This is reference URL: https://reqres.in/ and post method is : REGISTER - SUCCESSFUL
Please help me .
Thanks
Aucun commentaire:
Enregistrer un commentaire