Unable to remove a card from dashboard with Metabase API

I am trying to remove a card from the dashboard with Metabase API.
However, the following error occurred and I could not delete it.

Metabase version:v0.43.0
API:https://www.metabase.com/docs/latest/api/dashboard.html#delete-apidashboardidcards

[Command]

curl -X DELETE \
     --insecure \
     -H "Content-Type: application/json" \
     -H "X-Metabase-Session: ${X_Metabase_Session}" \
     -d  "{\"dashcardId\": 503}" \
     ${ADDRESS}/api/dashboard/24/cards

[Response]

{"errors":{"dashcardId":"value must be a valid integer greater than zero."}}

Could anyone help me?

Hi @yahi
dashcardId is a URL parameter, not a body:
https://www.metabase.com/docs/latest/api/dashboard.html#delete-apidashboardidcards

The best way to learn the API, is to just use Metabase while having your browser developer Network-tab open and looking at the request, and what data is being send/received.

Thank you for your answer.
I tried URL parameter.

[Command1]

curl -X DELETE \
     --insecure \
     -w '%{http_code}\n' \
     -H "Content-Type: application/json" \
     -H "X-Metabase-Session: ${X_Metabase_Session}" \
     ${ADDRESS}/api/dashboard/24/cards?dashcardId=503

⇒ I got status code "204".

Then I checked the dashboard in my browser, but the card(ID:503) was not removed from the dashboard(ID:24).

[Command2]

curl -X GET \
     --insecure \
     -H "Content-Type: application/json" \
     -H "X-Metabase-Session: ${X_Metabase_Session}" \
     ${ADDRESS}/api/dashboard/24 | jq .ordered_cards[].card_id

⇒ Card with ID 503 still exists.

Am I doing something wrong?
I would appreciate your advice.

@yahi Try doing it in your browser, look in the Network-tab and right-click to copy the request as cURL.

When I tried it in my browser and looked at the Network-tab, I noticed my mistake.
I should have specified not "card id" but "id" in the URL parameter.

The problem have been solved.
I am grateful for your support.

1 Like