Page 1 of 1

[JSON API] label.add request

Posted: Sun Jan 15, 2017 12:05 pm
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

Re: lable.add json request

Posted: Sun Jan 15, 2017 4:00 pm
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]

Re: lable.add json request

Posted: Sun Jan 15, 2017 7:37 pm
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.

Re: lable.add json request

Posted: Mon Jan 16, 2017 1:02 am
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

Re: lable.add json request

Posted: Mon Jan 16, 2017 5:38 am
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

Re: lable.add json request

Posted: Mon Jan 16, 2017 9:41 am
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.

Re: lable.add json request

Posted: Tue Jan 17, 2017 7:58 pm
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

Re: [JSON API] label.add request

Posted: Wed Jan 18, 2017 6:45 pm
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.