kanboard / python-api-client

Python API Client for Kanboard
https://pypi.org/project/kanboard
MIT License
79 stars 26 forks source link

Getting error at kanboard.Client( #36

Open bdika opened 6 months ago

bdika commented 6 months ago

Can't get the following to work(adjusted for my url):

import kanboard

kb = kanboard.Client('http://localhost/jsonrpc.php', 'jsonrpc', 'your_api_token') project_id = kb.create_project(name='My project') task_id = kb.create_task(project_id=project_id, title='My task title')

Tried

from kanboard import client

without any luck.

Any help much appreciated.

Thanks.

Bill Dika

AloisMahdal commented 6 months ago

What error are you getting?

Are you sure kanboard is running at localhost:80 and the user & API token are both correct?

AloisMahdal commented 6 months ago

By the way, I actually use the API like this:

kc = kanboard.Client(...)
kc.execute(
    method='createTask',
    project_id=1,
    title="hello",
    description="world",
)

and learn method names and arguments from the API documentation, eg. this page for createTask: https://docs.kanboard.org/v1/api/task_procedures/#createtask

bdika commented 6 months ago

Hi Alois:

Thanks for the response.

The error I am getting is: ^C./newtask.py: line 4: syntax error near unexpected token `('

My kanboard is not running on localhost. Here is my url entry: kb = kanboard.Client(url="http://192.168.xx.xxx:xxx15/jsonrpc.php", username="bdika", password="6765...")

Does it have to be localhost and port 80?

Bill Dika

On Tue, 27 Feb 2024 at 10:55, Alois Mahdal @.***> wrote:

By the way, I actually use the API like this:

kc = kanboard.Client(...) kc.execute('createTask', {'project_id': 1, 'title': "hello", 'description': "world"})

and learn method names and arguments from the API documentation, eg. this page for createTask: https://docs.kanboard.org/v1/api/task_procedures/#createtask

— Reply to this email directly, view it on GitHub https://github.com/kanboard/python-api-client/issues/36#issuecomment-1966879811, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACN2RLPMGYYG7GC6EHKEIOTYVX6XFAVCNFSM6AAAAABD4HKC36VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRWHA3TSOBRGE . You are receiving this because you authored the thread.Message ID: @.***>

AloisMahdal commented 6 months ago

It can be any host:port as long as it matches the URL.

Apparently you have syntax error in your newtask.py script, that has nothing to do with kanboard.

The syntax error was not in either of the snippets you have provided.

bdika commented 6 months ago

Hi Alois:

Thanks for the response.

I had my python environment messed up but now have it working and can create a project and task.

My objective is to try and create backup and restore python scripts using getAllTasks (for backup) and create tasks (for restore).

Do you think this is possible or I'm I completely off base? I have some experience using python but am not a programmer.

Thanks again.

Bill Dika

On Wed, 28 Feb 2024 at 02:29, Alois Mahdal @.***> wrote:

It can be any host:port as long as it matches the URL.

Apparently you have syntax error in your newtask.py script, that has nothing to do with kanboard.

The syntax error was not in either of the snippets you have provided.

— Reply to this email directly, view it on GitHub https://github.com/kanboard/python-api-client/issues/36#issuecomment-1968385340, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACN2RLPL24ND6SMNWJQSFELYV3MFLAVCNFSM6AAAAABD4HKC36VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRYGM4DKMZUGA . You are receiving this because you authored the thread.Message ID: @.***>

bdika commented 6 months ago

Hi Alois:

I tried this: backup.txt = kc.execute('getAllTasks', {'project_id': 2, 'status_id': 1})

but I get this error: TypeError: Client.execute() takes 2 positional arguments but 3 were given

Thanks.

Bill Dika

On Wed, 28 Feb 2024 at 16:15, Bill Dika @.***> wrote:

Hi Alois:

Thanks for the response.

I had my python environment messed up but now have it working and can create a project and task.

My objective is to try and create backup and restore python scripts using getAllTasks (for backup) and create tasks (for restore).

Do you think this is possible or I'm I completely off base? I have some experience using python but am not a programmer.

Thanks again.

Bill Dika

On Wed, 28 Feb 2024 at 02:29, Alois Mahdal @.***> wrote:

It can be any host:port as long as it matches the URL.

Apparently you have syntax error in your newtask.py script, that has nothing to do with kanboard.

The syntax error was not in either of the snippets you have provided.

— Reply to this email directly, view it on GitHub https://github.com/kanboard/python-api-client/issues/36#issuecomment-1968385340, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACN2RLPL24ND6SMNWJQSFELYV3MFLAVCNFSM6AAAAABD4HKC36VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRYGM4DKMZUGA . You are receiving this because you authored the thread.Message ID: @.***>

AloisMahdal commented 6 months ago

You need to call the Client.execute() method as I have shown above: with the method name as single positional parameter, and the method-specific arguments as keyword arguments, not as a sinlge dictionary.

kc.execute('getAllTasks', project_id=2, status_id=1)

If you have the method-specific arguments already collected in a dictionary, you can use ** Python syntax to convert them into keyword arguments:

my_params = {'project_id': 2, 'status_id': 1})
kc.execute('getAllTasks', **my_params)
AloisMahdal commented 6 months ago

Regarding your backup strategy, while it's technically possible to use API to collect relevant data to a file, I would not go that way if the goal was simply to back up the contents.

I would look for recommendation in Kanboard docs, but the best method will depend on how you have Kanboard deployed. For example, I use quay.io/kanboard/kanboard container, with a write-enabled directory mounted where Kanboard is storing its files including config, db.sqlite and attachments. Simply backing up the directory using borg backup is enough in my case. (Shutting down the container before the backup and bringing it back afterwards would be preferable; I take the risk of not doing so in my case.)

As I said, by collecting the data using the API you would have to collect not just tasks but also other things like users, swimlanes, columns, projects, comments and much more. Also you would have to figure out how to store the data for later. And eventually it could turn out that not all could be restored 100% using API.

It's just not the right tool for the job.

bdika commented 6 months ago

Thank you Alois.

I greatly appreciate your responses.

I have kanboard deployed as a TrueCharts app on TrueNas Scale operating system. The file system is ZFS, which I am not familiar with. The database used by TrueCharts is postgres and they do not provide an option to use sqlite3 (which would solve my problem if I knew where to go in the file system to find the file). TrueNas Scale is based on linux but is much different than anything I have used before. TrueCharts and TrueNas offer backup solutions but mainly for the entire TrueNas system. I am very new to TrueNas Scale operating system and TrueCharts apps but will keep plugging along.

I have browser access to my kanboard application and was looking to automate a backup solution from there.

Thanks again for your help.

Bill Dika

On Sun, 3 Mar 2024 at 08:47, Alois Mahdal @.***> wrote:

Regarding your backup strategy, while it's technically possible to use API to collect relevant data to a file, I would not go that way if the goal was simply to back up the contents.

I would look for recommendation in Kanboard docs, but the best method will depend on how you have Kanboard deployed. For example, I use quay.io/kanboard/kanboard container, with a write-enabled directory mounted where Kanboard is storing its files including config, db.sqlite and attachments. Simply backing up the directory using borg backup is enough in my case. (Shutting down the container before the backup and bringing it back afterwards would be preferable; I take the risk of not doing so in my case.)

As I said, by collecting the data using the API you would have to collect not just tasks but also other things like users, swimlanes, columns, projects, comments and much more. Also you would have to figure out how to store the data for later. And eventually it could turn out that not all could be restored 100% using API.

It's just not the right tool for the job.

— Reply to this email directly, view it on GitHub https://github.com/kanboard/python-api-client/issues/36#issuecomment-1975169993, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACN2RLL4JFGG456IZPXM6VLYWMSVPAVCNFSM6AAAAABD4HKC36VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZVGE3DSOJZGM . You are receiving this because you authored the thread.Message ID: @.***>

AloisMahdal commented 5 months ago

No worries, I hope you will (or have) find out how to solve your issue.

I'm not familiar with TrueNAS, but since it looks to be open solution, I'd guess there indeed is a way to get access to the SQL instance more directly, eg. via SSH. You just probably need to dig a little bit deeper.

If you are still stuck, you could try talking to truenas community. For example, I see they have a relatively active IRC channel #truenas on Libera IRC and there might be other platforms as well.

Anyway, since there does not seem to be any confirmed issue with kanboard itself, please consider closing this issue.

bdika commented 5 months ago

Hi Alois:

I took it off of truenas and put it on a Debian server and now backup the sqlite database daily with a cron job.

Thanks for all your help.

Bill Dika

On Fri, 5 Apr 2024 at 06:46, Alois Mahdal @.***> wrote:

No worries, I hope you will (or have) find out how to solve your issue.

I'm not familiar with TrueNAS, but since it looks to be open solution, I'd guess there indeed is a way to get access to the SQL instance more directly, eg. via SSH. You just probably need to dig a little bit deeper.

If you are still stuck, you could try talking to truenas community. For example, I see they have a relatively active IRC channel #truenas on Libera IRC and there might be other platforms as well.

Anyway, since there does not seem to be any confirmed issue with kanboard itself, please consider closing this issue.

— Reply to this email directly, view it on GitHub https://github.com/kanboard/python-api-client/issues/36#issuecomment-2039475665, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACN2RLMV2DPQIUCGHHX5ZNLY3Z6H5AVCNFSM6AAAAABD4HKC36VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZZGQ3TKNRWGU . You are receiving this because you authored the thread.Message ID: @.***>