how can I transfer this Curl command to Java http post:
curl --insecure -XPOST -H 'Authorization: XXXXX' -F 'Name=test name' -F 'text=test content123456' 'http://serverhost.com/api/index.php?action=send'
Thanks guys.
I've already try,but I think there may have a better way.
URL url = new URL(reqUrl);
URLConnection urlConnection = url.openConnection();
urlConnection.setDoOutput(true);
urlConnection.setRequestProperty("X-Requested-With", "Curl");
urlConnection.setRequestProperty("content-type", "application/x-www-form-urlencoded");
urlConnection.setRequestProperty("Authorization", authorization);
OutputStreamWriter out = new OutputStreamWriter(urlConnection.getOutputStream());
out.write(reqBody);
out.flush();
out.close();