gpt4 book ai didi

java - 使用 Rest Assured GET 方法获取错误代码 503

转载 作者:行者123 更新时间:2023-12-02 09:18:56 25 4
gpt4 key购买 nike

我使用放心的 GET 方法收到错误代码 503。这是代码。

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

它给了我 503 错误。相同的 API 在 Postman 中运行良好。请提出建议。

最佳答案

您的代码需要进行如下更正。

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

关于java - 使用 Rest Assured GET 方法获取错误代码 503,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58831738/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com