如何在Java中使用Rest-assured使用多部分文件附件?

时间:2019-01-09 04:08:56

标签: java rest rest-assured

我正在尝试使用具有multipart / form-data的保证来执行发布请求,该请求包含带有url的参数和要附加的文件

下面是我正在尝试获得握手错误的代码 如何附加带有url的文件?

RequestSpecification httpRequest = RestAssured
                                    .given()
                                    .relaxedHTTPSValidation()
                                    .cookie("SESSION", cookieVal)
                                    .header("Content-Type", "multipart/form-data")
                                    .header("accept","application/json")
                                    .multiPart(new File("CorporateWallpaper.jpg")) ;

Response response = httpRequest.request().post(url);
System.out.print(response.getStatusCode());

实际结果

javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake
    at java.base/sun.security.ssl.SSLSocketImpl.handleEOF(SSLSocketImpl.java:1321)
    at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1160)
    at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1063)
    at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:402)
    at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:533)

1 个答案:

答案 0 :(得分:0)

不太确定您的环境。 找到此link,可以一次检查协议版本。