Post
Topic
Board Development & Technical Discussion
Re: Accessing MT Gox API from Java
by
holgero
on 03/07/2011, 13:18:13 UTC
This works for me:
Code:
        final URL url = new URL("https://mtgox.com/code/getFunds.php");
        final HttpsURLConnection urlConn = (HttpsURLConnection) url.openConnection();
        urlConn.setDoInput(true);
        urlConn.setDoOutput(true);
        urlConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
        urlConn.setRequestMethod("POST");
        final DataOutputStream printout = new DataOutputStream(urlConn.getOutputStream());
        final String content = "name=" + URLEncoder.encode(USERNAME, "UTF-8") + "&pass=" + URLEncoder.encode(PASSWORD, "UTF-8");
        printout.writeBytes(content);
        printout.flush();
        printout.close();

Did you forget to URLEncode your username and password? Or is the typo where you set the "Content-Type" to
Code:
"application/x-www- form-urlencoded"
really there?