mbezzi
April 12, 2024, 10:31am
1
Hello,
Metabase API documentation up to v0.46 describes two APIs to add/delete cards to/from existing dashboards, namely:
POST /api/dashboard/:id/cards
DELETE /api/dashboard/:id/cards
It seems to me that from v0.47 on these two APIs suddenly disappeared without even being deprecated. As a result a python script I have that use these now gets:
"API endpoint does not exist."
Is this expected?
Are there new ways to accomplish the same with Metabase versions > 0.46?
Thanks in advance!
mario
TonyC
April 12, 2024, 11:03am
2
Indeed there was a refactoring in which we removed post and delete endpoints. Everything now is handled by PUT, for reference
metabase:master
← metabase:dashboard-bulk-create-delete
opened 09:26AM - 29 Mar 23 UTC
Milestone 0 of https://github.com/metabase/metabase/issues/29502
### Motivati… on
Currently, the APIs we used to create and delete dashcards are not bulked, which means if you edit a dashboard and add 5 cards to it, FE will calls `POST /dashboard/cards` 5 times.
That's not cool and we want to do bulk operations instead. So to do that we'll Remove
- `DELETE /api/dashboard/:id/cards`
- `POST /api/dashboard/:id/cards`
Update `PUT /api/dashboard/:id/cards` to handle bulks create/update/delete at the same time.
it takes a payload with keys `cards`
- to create cards, include a card with a negative id
- to delete cards, don't include that card in the payload
- to update cards, update card information in the cards payload
FE PR (already merged onto this branch): https://github.com/metabase/metabase/pull/29762
### Demo
https://user-images.githubusercontent.com/37751258/231255437-1ab4e592-c3c3-44b6-baf5-a36579139549.mov
Adding and removing cards and confirming revision history is correct.
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/metabase/metabase/29641)
mbezzi
April 12, 2024, 11:15am
3
Thank you Tony, appreciated!
Will you update the documention for PUT /api/dashboard/:id/cards
?
Thanks again,
mario