简体   繁体   中英

Getting error code 503 with Rest Assured GET method

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.

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM