Sending file to server causes java exception

I’m testing web uploading api. When trying to sending a pic to server, it causes an exception.

(Stack trace: java.io.IOException: Error writing to server

at sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:699)

at sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:711)

at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1585)

at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)

at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)

at com.kms.katalon.core.webservice.common.RestfulClient.response(RestfulClient.java:170)

at com.kms.katalon.core.webservice.common.RestfulClient.sendPostRequest(RestfulClient.java:110)

at com.kms.katalon.core.webservice.common.RestfulClient.send(RestfulClient.java:53)

at com.kms.katalon.controller.WebServiceController.sendRequest(WebServiceController.java:39)

at com.kms.katalon.composer.webservice.parts.RestServicePart$4.run(RestServicePart.java:152)

at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:119)

)

I used this tutorial Flask – File Uploading, however it works when just simply use browser to send the request.