It's still not working. I'm pretty sure it's the json I'm sending, but looking at the examples for other languages isn't enough for me to go on.
URL url = new URL(BITCOIN_DAEMON);
URLConnection conn = url.openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setUseCaches(false);
conn.setRequestProperty("Content-Type", "text/plain");
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(
conn.getOutputStream());
JSONObject jsonObject = new JSONObject();
jsonObject.put("getinfo", "");
jsonObject.writeJSONString(outputStreamWriter);
outputStreamWriter.flush();
outputStreamWriter.close();
DataInputStream input = new DataInputStream(conn.getInputStream());
I get a 400 error on the last line. Does anyone know what I'm doing wrong?
Edit: The JSONObject was wrong, this one works:
JSONObject jsonObject = new JSONObject();
jsonObject.put("method", "getinfo");
jsonObject.put("params", null);