Author

Topic: Server returned HTTP response code: 500 for URL: http://127.0.0.1:8332 (Read 2677 times)

member
Activity: 87
Merit: 10
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.

Code:
              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:
Code:
JSONObject jsonObject = new JSONObject();

jsonObject.put("method", "getinfo");
jsonObject.put("params", null);
member
Activity: 87
Merit: 10
Did you set it up as a server?
(Under ~/.bitcoin NIX & AppData/bitcoin for Windows)
Not properly. I set the name and password but missed the "server=1" flag, thanks.
sr. member
Activity: 322
Merit: 250
Do The Evolution
Did you set it up as a server?
(Under ~/.bitcoin NIX & AppData/bitcoin for Windows)
member
Activity: 87
Merit: 10
I'm trying to connect to bitcoind from java but I'm getting a 500 error, is there example code around for how to set it up?

I get a json error string when I connect from a browser, so it looks like bitcoind is running properly.
Jump to: