Author Topic: Webui add torrent from .torrent file  (Read 61 times)

basecase

  • Newbie
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Webui add torrent from .torrent file
« on: September 08, 2019, 03:58:52 pm »
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?

basecase

  • Newbie
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Webui add torrent from .torrent file
« Reply #1 on: September 09, 2019, 11:44:56 am »
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]
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]
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.

basecase

  • Newbie
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Webui add torrent from .torrent file
« Reply #2 on: September 13, 2019, 12:18:33 pm »
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]
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.