wekan-python-api-client
wekan-python-api-client copied to clipboard
Can't create/modify cards and boards?
It seems this python api doesn't allow for modification/creation of data, just retrieving... is that correct?
or I'm missing something?
Some info about modifying cards etc with Python at https://github.com/wekan/wekan/issues/2284
I couldn't find info on how to change color of a card, how to move cards up and down in a list and how to move the card to a different list. I tried change the list in the card data and modify it using a PUT call like I'm doing to modify the title, but doesn't work.
Just some context of what I'm doing: I'm using a weekan board as a frontend GUI for a custom made backup system. The board acts as the backup database, with one list for each LTO tape.
The system automatically creates cards for each project, and updates then with some info, like disk usage, last modification date, etc. (moving card up and down is perfect to sort card by disk usage, with the bigger ones at the top!)
That way, the responsible for flagging projects for backup just move the cards from "onGoing" to "send to LTO", and the system will start copying it.
The basics is working, but now I wan't to change the card color for when something is being staged for backup, when the backup is actually happening and when it's done.
Also, I need to make the system move the card from "Send to LTO" to the actual LTO Tape list where it was copied to... so I need to figure how to move cards from one list to another.
It's all being done in python, btw...
The moving cards from one list to another will also help to simulate a "read only" list, basically preventing someone to accidentally move a card off a LTO tape list by moving it back to the list it belongs. ( All backed up cards have some extra data in the title to tell what LTO tape they belong to)
Login to Wekan as admin user with form data: https://github.com/wekan/wekan/wiki/REST-API#example-call---as-form-data
You get bearer token, use it to edit card: https://wekan.github.io/api/v2.71/?python#edit_card
I'll try to find more help later.
Thanks lots!!
I never found that https://wekan.github.io/api/v2.71/ link!!! really appreciate!!!
Regarding the token, wekan-python-api-client retrieves it, so I just need to use the proper parameters to modify the cards.
I think I can figure things out now with that!!
I'll add a proper modify() function to the card class soon...
Cheers!
You get bearer token, use it to edit card: https://wekan.github.io/api/v2.71/?python#edit_card
So, I did a test using
r = requests.put('/api/boards/{board}/lists/{list}/cards/{card}', params={
"color" : "magenta"
}, headers = headers)
and nothing happens. The request executes as it should, and I receive the proper result in r
as of the documentation ({ "_id": "<card id>"}
), but the color doesn't change.
I tried description
as well and also nothing happens.
If I try a bogus paramereter, like "cow" : "mooo"
and it fails... so at least it's processing the params
dict as it should... but it's not changing anything.
I'm using the bearer token which __init__.py
retrieves and stores in the WekanApi class.
Basically, this is the code I'm adding to api_call() method, when it's called to modify cards:
headers = {
'Content-Type': 'multipart/form-data',
'Accept': 'application/json',
'Authorization': "Bearer {}".format(self.token), # without "Bearer ", it throws an error
}
api_response = self.session.put(
"{}{}".format(self.api_url, url),
params={ "color" : "magenta" },
headers=headers if authed else {},
proxies=self.proxies
)
where url
variable has the correct path for the card. I known the url
is correct, since doing the same call but passing the data=self.data
instead of params
, works to modify the title of the card. (by changing self.data['title']
)
any ideas why it's not changing anything even returning the correct result instead of an error??
I'm running wekan v2.75.0, using docker, btw...
To use API with Docker, you need WITH_API=true https://github.com/wekan/wekan/blob/devel/docker-compose.yml#L223
To use API with Docker, you need WITH_API=true https://github.com/wekan/wekan/blob/devel/docker-compose.yml#L223
Yep... I'm running with that... but params=
still doesn't work. Any idea why or how can I debug it?
Hi,
Do you solve the problem ? I try to automate creation of cards with REST API but i'm unable tu update any field in cards (I can create it but not edit...)
Thanks
@hradec
I did merge your PR. Is anything missing still?
Also see https://github.com/wekan/wekan/blob/master/api.py