It’s not working…POST request using Rest Assured

import org.json.simple.JSONObject;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import io.restassured.RestAssured;
import io.restassured.response.Response;
import io.restassured.specification.RequestSpecification;

public class SimplePostTest {
RequestSpecification httpRequest;
Response response;

public void Setup()
RestAssured.baseURI = “”;
httpRequest = RestAssured.given();
JSONObject requestParams = new JSONObject();

requestParams.put(“FirstName”, “Poonam”); // Cast
requestParams.put(“LastName”, “Agrawal”);

requestParams.put(“UserName”, “simpleuser001”);
requestParams.put(“Password”, “password1”);
requestParams.put(“Email”, “”);

// Add the Json to the body of the request
// Post the request and check the response
response =“/register”);


public void ResponseValidationTest()
int StatusCode = response.getStatusCode();
String statusLine = response.getStatusLine();
String successCode = response.jsonPath().get(“SuccessCode”);

//Assert.assertEquals(StatusCode, “201”);


public void cleanUp()
//httpRequest = null;
//response = null;

Default Asked on June 27, 2018 in Program QA Automation.
Add Comment
  • 1 Answer(s)

    If you specify what is output you are facing then it will be easy to check it. However I have used your code and it works fine. I can see it working.

    The code is used as it is and below is output. Just changed input values to create user.

    RE: It's not working...POST request using Rest Assured

    Default Answered on July 6, 2018.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.