Suggestions and discussion of future versions
jacroe
New User
Posts: 4 Joined: Fri Sep 28, 2012 8:05 am
Post
by jacroe » Fri Sep 28, 2012 8:10 am
I'm trying to add a local torrent file to Deluge using the web-ui's jsonRPC. I'm using this bit of code:
Code: Select all
curl -b cookies.txt --compressed -i -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"method":"web.add_torrents","params":[{"path":"/tmp/ubuntu-12.04.1-desktop-amd64.iso.torrent","options":null}],"id":1}' http://localhost:8081/json
And I'm getting a "String indices must be integers" error message. The error number is 3. How can I fix this?
Cas
Top Bloke
Posts: 3681 Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland
Post
by Cas » Fri Sep 28, 2012 11:09 am
It is because the method
web.add_torrents can take multiple torrents so it is a list of dicts and when providing the params it is also a list so you require an extra pair of square brackets.
Code: Select all
curl -b cookies.txt --compressed -i -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"method":"web.add_torrents","params":[[{"path":"/tmp/ubuntu-12.04.1-desktop-amd64.iso.torrent","options":null}]],"id":1}' http://localhost:8081/json
jacroe
New User
Posts: 4 Joined: Fri Sep 28, 2012 8:05 am
Post
by jacroe » Fri Sep 28, 2012 3:52 pm
Ah, thank you. I thought I had included enough brackets, but I suppose not. Thank you very much.