Communicating with the Transmission RPC via cURL

A proper library is your best bet, but maybe you don't have that and you just want to use cURL to check something real quick.

First, send your request to the RPC server and it'll error out because you don't have a X-Transmission-Session-Id header. You'll get this header sent back to you in the response body:

$ cat req.json
{
  "arguments": {
    "fields": ["id", "name"],
  },
  "method": "torrent-get"
}

$ curl http://localhost:11210/transmission/rpc -u USER:PASSWD -d @req.json # linebreaks added to response to make it easier to read
<h1>409: Conflict</h1>
<p>Your request had an invalid session-id header.</p>
<p>To fix this, follow these steps:<ol>
  <li> When reading a response, get its X-Transmission-Session-Id header and remember it
  <li> Add the updated header to your outgoing requests
  <li> When you get this 409 error message, resend your request with the updated header
</ol></p>
<p>This requirement has been added to help prevent <a href="https://en.wikipedia.org/wiki/Cross-site_request_forgery">CSRF</a> attacks.</p>
<p><code>X-Transmission-Session-Id: LONGHASH</code></p>

Next, resend the same request with this new header:

$ curl http://localhost:11210/transmission/rpc -u USER:PASSWD -d @req.json -H 'X-Transmission-Session-Id: LONGHASH'

Refs: https://github.com/transmission/transmission/blob/main/docs/rpc-spec.md


Created: 2024-01-18
Last Updated: 2024-01-23

← Back