[JSON API] label.add request

Suggestions and discussion of future versions
Post Reply
BoKKeR
New User
New User
Posts: 9
Joined: Sun Jan 15, 2017 11:57 am

[JSON API] label.add request

Post by BoKKeR »

hey I am trying to add a label through a json request and cant get my head around it.

Code: Select all

"{"method": "label.add", "params": ["label"], "id": "5"}"
this dosent work

label plugin is enabled. there isnt much documentation on the api to be honest
Cas
Top Bloke
Top Bloke
Posts: 3679
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: lable.add json request

Post by Cas »

It's exported from the plugin core and looking at the source js ui code you can see usage:

Code: Select all

deluge.client.label.add
[/url][/s]
Edit:

Code: Select all

label.add
[/url]
BoKKeR
New User
New User
Posts: 9
Joined: Sun Jan 15, 2017 11:57 am

Re: lable.add json request

Post by BoKKeR »

I looked at the source and it shows that this should work,

Code: Select all

"{"method": "deluge.client.label.add", "params": ["label"], "id": "5"}"
but it wont.
Cas
Top Bloke
Top Bloke
Posts: 3679
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: lable.add json request

Post by Cas »

Sorry it is actually label.add I don't use the json-api much but it does work. It is much more helpful if you can provide the error you are seeing.

For reference you can list all methods with "method": "system.listMethods"

Here are the working curl examples:

Code: Select all

curl -b cookies.txt --compressed -i -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"method": "label.add", "params": ["new"], "id": 1}' http://localhost:8112/json

Code: Select all

curl -b cookies.txt --compressed -i -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"method": "system.listMethods", "params": [], "id": 1}' http://localhost:8112/json
Oh you are right about documentation, when we lost the website last year I didn't realise that json section wasn't restored. It wasn't much but better than nothing ;) https://web.archive.org/web/20150926160 ... index.html
BoKKeR
New User
New User
Posts: 9
Joined: Sun Jan 15, 2017 11:57 am

Re: lable.add json request

Post by BoKKeR »

about the error the problem is that I cant get the debug to show json errors. I start deluge-debug.exe -L debug but it does not show any json related errors. I guess I am missing something
Cas
Top Bloke
Top Bloke
Posts: 3679
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: lable.add json request

Post by Cas »

The errors should be returned from the request.

Code: Select all

HTTP/1.1 200 OK
Transfer-Encoding: chunked
Date: Mon, 16 Jan 2017 00:52:07 GMT
Content-Encoding: gzip
Content-Type: application/x-json
Server: TwistedWeb/16.0.0

{"id": 1, "result": null, "error": {"message": "Unknown method", "code": 2}}
If you are running deluge-web or deluged separately then you would need to log them for critical errors.
BoKKeR
New User
New User
Posts: 9
Joined: Sun Jan 15, 2017 11:57 am

Re: lable.add json request

Post by BoKKeR »

my bad boss just got it to work. Had to implement a decompresser and remake half of my class as I was not working with any response before
BoKKeR
New User
New User
Posts: 9
Joined: Sun Jan 15, 2017 11:57 am

Re: [JSON API] label.add request

Post by BoKKeR »

Actually now I am getting a problem with a few calls because they time out, calls like label.get_labels , how would I go about debugging this ? -L critical dosent return anything. and obviously there is no response.
Post Reply