mirror of
https://github.com/plankanban/planka.git
synced 2026-02-25 03:14:50 +03:00
Creating a new card by REST API #208
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @andreasgerstmayr on GitHub (Jun 24, 2022).
I'm looking for a way to create a new card with the REST API.
Afaics I need the
POST /api/boards/:boardId/cardsroute, with these parameters:ecc45c7a9e/server/api/controllers/cards/create.js (L20-L31)I can get the the
boardIdby calling/api/projectsand looking atincluded.boardsof the response, but I don't know how to get thelistId.I think the
boards/showendpoint would list alllists, but I'm always getting a bad request error:ecc45c7a9e/server/api/controllers/boards/show.js (L23-L26)Is there a security check missing, or can this conditional be safely removed?
Second question: What is the correct value for the
positionparameter, if I want to place the new card at the end? Is there an easier way other than requesting all cards, filter them for the currentlistand then usemax(position)+1?And thanks for this great project, I love the UI/UX, and so far everything is working perfectly :)
@meltyshev commented on GitHub (Jun 24, 2022):
Hi!
This endpoint needs to be fixed, I'll try it now. I think I did this check because of the
sails.sockets.joinat the bottom.You can find how the position is calculated in
client/src/selectors/core.js. To insert somewhere in the middle you need to get the previous card and next card and then use the formulaprevPosition + (nextPosition - prevPosition) / 2. If you want to place the card at the end, just get the position for the last card and add 65535 to it.At some point the positions will be recalculated automatically when the gap between cards will be a very small number, this occurs on the server and then the client side is notified of the changes via socket.
🙏
@andreasgerstmayr commented on GitHub (Jun 27, 2022):
Thanks a lot @meltyshev!
I just tried the new version 1.3.2 including
3b3bff1b6band it works perfectly.For reference, this is my minimal Python API client (probably there's a better way to write or generate an API client, but it works for my usage - creating new cards. doesn't support card positions yet):