asp.net-web-apiutorrent

uTorrent API add url giving 400 invalid request


Why is it giving 400 bad request for the following code. We want to schedule a torrent using web API of utorrent.

import urllib2, base64

username = "username"
password = "password"

request = urllib2.Request("http://<my_ip>:<torrent_webapi_port>/gui/?action=add-url&s=%s" % urllib2.quote("http://torcache.net/torrent/CDADFE86960C3255EB37B15F7E45C281F3A3C937.torrent?title=[kickass.to]arrow.s02e14.hdtv.x264.lol.ettv"))
base64string = base64.encodestring('%s:%s' % (username, password)).replace('\n', '')
request.add_header("Authorization", "Basic %s" % base64string)
result = urllib2.urlopen(request)
print result.read()

Solution

  • Please read the following Token Authentication system.

    You should send an extra param called "token=" in all your request. You can get the token_value from

    http://:utorrent_web_api_port/gui/token.html

    http://www.utorrent.com/community/developers/webapi#devs4

    Detailed explanation is given in the following link.

    https://github.com/bittorrent/webui/wiki/TokenSystem