Reputation: 313
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.
Upvotes: 0
Views: 1522
Reputation: 2000
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();
Upvotes: 1