Howdy pardner!

These here forums are read-only. Click here to go to the new forums, where you can actually post and stuff!

Sorry for the inconvenience

-Andrew

I'm making a client in Java (Yes, Java, get over it Hetal) and I'm not able to use /api/login/ with much luck.

I get the token using:

connect = new URL("https://www.classicube.net/api/login/");
HttpURLConnection conn = (HttpURLConnection) connect.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("GET");

And this works with success, but no matter how I try POST the token back, it will keep failing, either saying it did not expect a token, or i get "java.io.IOException: Server returned HTTP response code: 400 for URL: https://www.classicube.net/api/login/"

I use this and i get response code 400:

HttpURLConnection conn2 = (HttpURLConnection) connect.openConnection();
conn2.setDoOutput(true);
conn2.setRequestMethod("POST");
DataOutputStream var13 = new DataOutputStream(conn2.getOutputStream());
var13.writeBytes("username=" + user);
var13.writeBytes("&password=" + password);
var13.writeBytes("&token" + token);
var13.close();
BufferedReader responseReader2 = new BufferedReader(new InputStreamReader(conn2.getInputStream()));

(I included the BufferedReader line because that is what gives me errors, without it I'm magically fine, but I cannot tell if my login was successful)

and sometimes it just downright fails to do anything at all, it just gives me an error saying that it did not expect a token????

UnknownShadow200 🔧 Wed Apr 12 at 7:26:34 (2017)

You're missing a = after &token

Writing up some java code, will reply later with it.

(Automerge)

https://gist.github.com/UnknownShadow200/8dff4ec7f9e26d90dd653161d8856773

++UnknownShadow200 posted:++

You're missing a = after &token

Writing up some java code, will reply later with it.

(Automerge)

https://gist.github.com/UnknownShadow200/8dff4ec7f9e26d90dd653161d8856773

Thanks for the help! This shows that I also have a lot to learn about java... What happened was, the equal sign, and that I forgot a cookie manager.

Your code was better in general, so I only copied the small amount of 62 lines

🛑 This thread has been set to read-only due to inactivity. 🛑