[JSON API] "String indices must be integers" error

Suggestions and discussion of future versions
Post Reply
jacroe
New User
New User
Posts: 4
Joined: Fri Sep 28, 2012 8:05 am

[JSON API] "String indices must be integers" error

Post by jacroe »

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
Top Bloke
Posts: 3681
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: "String indices must be integers" error

Post by Cas »

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
New User
Posts: 4
Joined: Fri Sep 28, 2012 8:05 am

Re: [JSON API] "String indices must be integers" error

Post by jacroe »

Ah, thank you. I thought I had included enough brackets, but I suppose not. Thank you very much.
Post Reply