Page 1 of 1
Webui add torrent from .torrent file
Posted: Sun Sep 08, 2019 1:58 pm
by basecase
So, using the webui I can add torrents just fine when i use a magnetlink url but I cannot seem to add one using a file. In the api documentation the binary_data_goes_here part throws me off. Does anybody have and example line for me?
Re: Webui add torrent from .torrent file
Posted: Mon Sep 09, 2019 9:44 am
by basecase
Just a little additional information. This line seems to be getting through to the server but I'm getting a strange error from the client.
Code: Select all
curl --header 'Content-Type: application/x-bittorrent' --data "torrents=41de2d6b93d8edc56a5145d2fe4723647c5dafb1.torrent" http://localhost:8080/api/v2/torrents/add
This command gives me this error when qbittorrent is opened in the terminal.
Code: Select all
bool Http::RequestParser::parsePostMessage(const QByteArray&) unknown content type: "application/x-bittorrent"
Http::RequestParser::ParseResult Http::RequestParser::doParse(const QByteArray&) message body parsing error
This leads me to believe qBittorrent doesn't recognize the binary format the api says it requires. I get the same error when I use --data-binary, --data, and switch out torrents for filename. I am not sure what the correct way to form the curl command, so I don't think it is a bug. We will see.
Re: Webui add torrent from .torrent file
Posted: Fri Sep 13, 2019 10:18 am
by basecase
UPDATE: For those in the same boat as me with the webui api, I figured out the way to use curl for the webui. To add a torrent with the webui, you have to use the --form content type instead of the --data type that you use with the magnetlink add. Here is an example of what worked for me.
Code: Select all
curl -X POST --form "savepath=$currentDIR" --form root_folder=false --form "torrents=@$torrentFileName" http://$QBT_HOST:$QBT_PORT/api/v2/torrents/add
So just use --form and an @ in front of the torrent file name.