Jump to content

400 Invalid Request using add-url with a magnet link


Recommended Posts

I'm trying to create an RSS magnet program in C#/WPF, unfortunately I can't see to get it to work. I am receiving 400 Invalid Request errors from the webui. This is a Linux 3.0 x86 install on a headless Ubuntu server.

At first, I thought it was that I wasn't including tokens, because I wasn't, but even after adding them it's still not working. The token is at the front so it shouldn't be crapping on its position. I'll be making the UI for customizing field values later, I just need it functional first.

string scheme = "http://";
string server = "";
string port = "8080";
string relativePath = "/gui/";
string tokenPath = scheme + server + ":" + port + relativePath + "token.html";
foreach (FeedItem item in LV_Parsed.SelectedItems)
WebClient tokenClient = new WebClient();
tokenClient.Credentials = new NetworkCredential("admin", "*ThePassword");
string tokenClientResponse = tokenClient.DownloadString(tokenPath);

string token = tokenClientResponse
.Replace("<html><div id='token' style='display:none;'>", "")
.Replace("</div></html>", "");
token = HttpUtility.UrlEncode(token);
// token value: n1nzpboWiGxVxqEs1VOTrxUoT3woSMsFAAAAAM8MYqEAAAAAw1gp4hefM1EAAAAA
string magnet = "magnet:?xt=urn:btih:";
string dumbName = item.Title;
string hash = item.Link.Replace("http://torrentz.eu/", "");

string path = scheme + server + ":" + port + relativePath + "?token=" + token + "&action=add-url&s="
+ HttpUtility.UrlEncode(magnet + hash + "&dn=" + dumbName);

string addResult = tokenClient.DownloadString(path);
addResult += "";

/* Path's Value (separated to make it easier to read):

Link to comment
Share on other sites

Just in case it has any bearing, this is what the About dialog in the web ui tells me. If I need a newer version of webui I need to know how to install it to Ubuntu

µTorrent Server

Copyright 2011 BitTorrent, Inc.

All Rights Reserved.

Client Information

Product Version 3.0

Source Revision 27079

Build Date 2012-04-17 19:51:48 -0700

UI Revision 27079

Peer ID UT300B

User-agent uTorrent/300B(27079)(server)

UPnP external address:

This was installed using the installer on this page:


Seeing as it was released almost a year ago, I'm betting its in some way out of date :/

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...


This topic is now archived and is closed to further replies.

  • Create New...