0

I am getting an error code 503 with rest assured GET Method. Here is the code.

RequestSpecification request = RestAssured.given();
Response post = request.log().all().relaxedHTTPSValidation().get(url);

It is giving me 503 error. The same API works fine in Postman. Please suggest.

  • 1
    5xx is a server issue, if it works fine in Postman but not with [rest-assured] invocation best to check the server logs for specific errors. Also pls post the postman details to check for any differences in the way the request is constructed. – SudhirR Nov 19 '19 at 03:15
  • Issue resolved after debugging in elb server.Issue was due to the host header value. – Murugesh Subramaniam Nov 19 '19 at 08:11

1 Answers1

1

Your code need to be corrected as below.

  /*
 * We can parameterize it using baseURI and basePath and send a request to get a customer using ID      
 */
        RestAssured.baseURI = "http://parabank.parasoft.com/";
        RestAssured.basePath = "parabank/services/bank/customers";  

        //For the request You can define the setup values which can be  reuse  .
        RequestSpecBuilder reqbuild=new RequestSpecBuilder();
        //Adding values like path parameters
        reqbuild.addPathParam("customers", "12212");
        //Add content type
        reqbuild.setContentType(ContentType.JSON);// or reqbuild.setContentType("application/json; charset=UTF-8" );
        //After that build it
        requestSpecfication=reqbuild.build()

given().spec(requestSpecfication).when().get("{customers}/").then().log().all();

Sameera De Silva
  • 1,722
  • 1
  • 22
  • 41