Rest 我试过使用POSTMAN API,但没有使用我的放心代码

Rest 我试过使用POSTMAN API,但没有使用我的放心代码,rest,automation,rest-assured,Rest,Automation,Rest Assured,将响应获取为“响应:tcp\U错误:发生通信错误:“操作超时” " 邮递员/卷发 curl -X POST \ http://IP:PORT/{endpoint} \ -H 'Accept: application/json' \ -H 'Accept-Encoding: gzip, deflate' \ -H 'Cache-Control: no-cache' \ -H 'Connection: keep-alive' \ -H 'Content-Length:

将响应获取为“响应:tcp\U错误:发生通信错误:“操作超时”
"

邮递员/卷发

    curl -X POST \
  http://IP:PORT/{endpoint} \
  -H 'Accept: application/json' \
  -H 'Accept-Encoding: gzip, deflate' \
  -H 'Cache-Control: no-cache' \
  -H 'Connection: keep-alive' \
  -H 'Content-Length: 5' \
  -H 'Content-Type: application/json' \
  -H 'Host: IP:PORT' \
  -H 'Postman-Token: 053670e6-44d4-4d03-96bf-ab1178b02d06,ffad205d-320a-4cd0-a63d-1687873fbf1d' \
  -H 'User-Agent: PostmanRuntime/7.19.0' \
  -H 'appkey: ACTUAL APP KEY' \
  -H 'cache-control: no-cache' \
  -d '{

}'
上述API的放心代码

RestAssured.baseURI = “http://IP”;
        RestAssured.port = port;
        RestAssured.useRelaxedHTTPSValidation();

        Response response = RestAssured.given()

                .header("Accept", "application/json")
                .header("Content-Type", "application/json")
                .header("appkey", “ACTUAL APPKEY”)
                .when()
                .get(“ENDPOINT”);

        System.out.println("Response: " + response.asString());

尝试在rest assured中设置编码器配置。它将解决这个问题

given().config(RestAssured.config().encoderConfig(encoderconfig.appendDefaultContentCharsetToContentTypeIfUndefined(false)));

发布代码,你尝试了什么,向我们展示来自Postman.Fenio的请求,更新代码和Postman请求详细信息如下: