API in python how to pass a list parameter


i manage to create simple tasks with Python and the API.
now what i expect is accesing parameters of such task.
In other words, translating this (which is working):
curl -u “admin:admin” -d ‘{“jsonrpc”: “2.0”, “method”: “getTaskMetadata”, “id”: 1, “params”: {“task_id”: 4}}’ http://localhost/kanban/jsonrpc.php

in python. however i do not know how to pass the parameters “params” (which is a type “list”:slight_smile:
I tried:

import kanboard

kb = kanboard.Client(url, user, pswd)

thank you for your help

What did you already try, what failed?

The JSON command with “CURL” is working

however the python code (present in my first post), is causing following error:

Traceback (most recent call last):

  • File “./k.py”, line 13, in *
  • tm=kb.getTaskMetadata(project_id=1,params={‘task_id’:4})*
  • File “/usr/local/lib/python3.8/dist-packages/kanboard.py”, line 106, in function*
  • return self.execute(method=self._to_camel_case(name), *kwargs)
  • File “/usr/local/lib/python3.8/dist-packages/kanboard.py”, line 183, in execute*
  • return self._do_request(headers, payload)*
  • File “/usr/local/lib/python3.8/dist-packages/kanboard.py”, line 152, in _do_request*
  • return self._parse_response(response)*
  • File “/usr/local/lib/python3.8/dist-packages/kanboard.py”, line 129, in _parse_response*
  • raise ClientError(message)*
    kanboard.ClientError: Invalid params

I’m not a python man, but:

  • According to the docs, the functions are not CamelCase.

project_id = kb.create_project(name=‘My project’)

  • You must use named arguments.

I would try


I just see that get_task_metadata has only one param, the task_id… so


should fit.

You get it.

The solution, is your last suggestion: tm=kb.get_task_metadata(task_id=4)

but the documentation, is not so easy to interpret that only 1 parameter is requiered:

Thanks a lot!

Remove the project_id. It’s not needed.

thanks again.
Last question:


 print (str(tm))

i get:
{'Componente': '', 'Fecha_Dispo': '', 'OP': '', 'Peso': '', 'Unidad': '15'}

what would be the saveTaskMetadata syntax?
kb.saveTaskMetadata(task_id=13, params={"Unidad":"99"})

is returning:

Traceback (most recent call last):
  File "./k.py", line 39, in <module>
    kb.saveTaskMetadata(task_id=13, params={"Unidad":"99"})
  File "/usr/local/lib/python3.8/dist-packages/kanboard.py", line 106, in function
    return self.execute(method=self._to_camel_case(name), **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/kanboard.py", line 183, in execute
    return self._do_request(headers, payload)
  File "/usr/local/lib/python3.8/dist-packages/kanboard.py", line 152, in _do_request
    return self._parse_response(response)
  File "/usr/local/lib/python3.8/dist-packages/kanboard.py", line 129, in _parse_response
    raise ClientError(message)
kanboard.ClientError: Invalid params

I answer my own question:
tm=kb.saveTaskMetadata(task_id=13, values={"Unidad":"99"})

however, this bring my to another point:
is there any place where to find the syntax of python class ? f.eg: why “value” and not “params”…

Because it’s documented.

Python methods are dynamically mapped to the API procedures: You must use named arguments.