[JSON API] label.add request

Suggestions and discussion of future versions
BoKKeR
New User
New User
Posts: 5
Joined: Sun Jan 15, 2017 11:57 am
OS or Distro: linux

[JSON API] label.add request

Postby BoKKeR » Sun Jan 15, 2017 12:05 pm

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: 3272
Joined: Mon Dec 07, 2009 6:04 am
OS or Distro: Ubuntu 16.04
Location: Scotland

Re: lable.add json request

Postby Cas » Sun Jan 15, 2017 4:00 pm

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

Edit:


BoKKeR
New User
New User
Posts: 5
Joined: Sun Jan 15, 2017 11:57 am
OS or Distro: linux

Re: lable.add json request

Postby BoKKeR » Sun Jan 15, 2017 7:37 pm

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: 3272
Joined: Mon Dec 07, 2009 6:04 am
OS or Distro: Ubuntu 16.04
Location: Scotland

Re: lable.add json request

Postby Cas » Mon Jan 16, 2017 1:02 am

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: 5
Joined: Sun Jan 15, 2017 11:57 am
OS or Distro: linux

Re: lable.add json request

Postby BoKKeR » Mon Jan 16, 2017 5:38 am

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: 3272
Joined: Mon Dec 07, 2009 6:04 am
OS or Distro: Ubuntu 16.04
Location: Scotland

Re: lable.add json request

Postby Cas » Mon Jan 16, 2017 9:41 am

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: 5
Joined: Sun Jan 15, 2017 11:57 am
OS or Distro: linux

Re: lable.add json request

Postby BoKKeR » Tue Jan 17, 2017 7:58 pm

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: 5
Joined: Sun Jan 15, 2017 11:57 am
OS or Distro: linux

Re: [JSON API] label.add request

Postby BoKKeR » Wed Jan 18, 2017 6:45 pm

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.


Return to “Development”

Who is online

Users browsing this forum: No registered users and 1 guest