1

i'm trying to test sending a magnet url to utorrent before i go ahead and finish writing my Android app.

first i fetch the token like the docs say

byte[] encodedLogin = (user.getUsername() + ":" + user.getPassword()).getBytes();
        String auth = "Basic " + Base64.encodeToString(encodedLogin, false);

Document doc = Jsoup.connect("http://" + user.getIpAddress() + ":" + user.getPort() + "/gui/token.html")
                .header("Authorization", auth)
                .get();

token = doc.getElementById("token").text();

which fetches the token properly (i think)

next i try to send a magnet url to utorrent with and without authorization and setting my token at the beginning like the docs suggest

Jsoup.connect("http://" + user.getIpAddress() + ":" + user.getPort() + "/gui/")
        .header("Authorization", auth)
        .data("token", token)
        .data("action", "add-url")
        .data("s", "magnet:?xt=urn:btih:8AC3731AD4B039C05393B5404AFA6E7397810B41").get();

but all i get is an error message like this (it becomes 401 error if i remove the Authorization header from the latter piece of code)

java.io.IOException: 400 error loading URL http://192.168.1.105:47240/gui/?token=OiBBhy1x7JuqvrB1xb88wJGLKH2hzC4KaOGBMtDjg1F3LFyx0LrkjaZGBk8AAAAA&action=add-url&s=magnet%3A%3Fxt%3Durn%3Abtih%3A10A28E56F3705DA09D06D76F0FD51B6116730C08

i tried turning off the token system from utorrent's advanced settings and the magnet link was sent successfully. however, i'd rather not do that.

the sad thing is i tried copying the url from the error message to my browser (changing the token obviously) and it worked fine!

please help!

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.