Bitcoin Forum
June 16, 2025, 10:26:51 PM *
News: Pizza day contest voting
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Server returned HTTP response code: 500 for URL: http://127.0.0.1:8332  (Read 2691 times)
elk-tamer (OP)
Member
**
Offline Offline

Activity: 87
Merit: 10


View Profile
July 11, 2011, 03:17:34 AM
 #1

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.
fabianhjr
Sr. Member
****
Offline Offline

Activity: 322
Merit: 250


Do The Evolution


View Profile
July 11, 2011, 03:22:10 AM
 #2

Did you set it up as a server?
(Under ~/.bitcoin NIX & AppData/bitcoin for Windows)

elk-tamer (OP)
Member
**
Offline Offline

Activity: 87
Merit: 10


View Profile
July 11, 2011, 03:49:54 AM
 #3

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.
elk-tamer (OP)
Member
**
Offline Offline

Activity: 87
Merit: 10


View Profile
July 12, 2011, 12:55:30 AM
Last edit: July 12, 2011, 03:06:54 AM by elk-tamer
 #4

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);
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!