deck icon indicating copy to clipboard operation
deck copied to clipboard

Reorder API has Changed?

Open gnilebein opened this issue 9 months ago • 10 comments

I have a few scripts that automatically move Nextcloud Deck cards to another stack when overdue. These no longer work with the current version.

I use this endpoint as described in the API:

/boards/{boardId}/stacks/{stackId}/cards/{cardId}/reorder

In my opinion, this was also used for the web interface.

However, the web interface now uses this endpoint:

/cards/{cardId}/reorder as the endpoint.

Has the API changed here and the documentation has not been adapted?

gnilebein avatar Mar 12 '25 08:03 gnilebein

@gnilebein As far as I know, the Rest API endpoints did not change. Please share system info and error messages.

luka-nextcloud avatar Mar 19 '25 13:03 luka-nextcloud

@gnilebein As far as I know, the Rest API endpoints did not change. Please share system info and error messages.

Thank you very much for your answer.. I was able to solve the problem myself by adapting my script. I have used this script in the past to move overdue cards from one stack to another.

<?php

// Dieses Script verschiebt Karten aus einem Stack "Warten" in einen anderen Stack, wenn das DueDate überschritten wurde.
// Es unterstützt mehrere Boards.

$boards = [
    ["id" => 6, "source" => 20, "destination" => 10]
];

$username = "USER";
$password = "PASSWORD";

// Funktion zum Senden von cURL-Requests
function sendCurlRequest($url, $method = "GET", $data = null)
{
    global $username, $password;

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Content-Type: application/json',
        'OCS-APIRequest: true',
        'Authorization: Basic ' . base64_encode($username . ":" . $password)
    ]);

    if ($method !== "GET") {
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
        if ($data !== null) {
            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
        }
    }

    $response = curl_exec($ch);
    
    if ($response === false) {
        error_log("cURL-Fehler: " . curl_error($ch));
    }

    curl_close($ch);
    return json_decode($response, true);
}

foreach ($boards as $board) {
    $url = "https://nextcloud.gnilebein.de/index.php/apps/deck/api/v1.1/boards/{$board['id']}/stacks/{$board['source']}";
    $cards = sendCurlRequest($url);

    if (!isset($cards['cards'])) {
        error_log("Fehler: Keine Karten gefunden für Board ID {$board['id']}");
        continue;
    }

    $data = ["order" => 0, "stackId" => $board['destination']];

    foreach ($cards['cards'] as $card) {
        if ($card['overdue'] > 1) {
            $moveUrl = "https://nextcloud.domain.tld/index.php/apps/deck/api/v1.1/boards/{$board['id']}/stacks/{$card['stackId']}/cards/{$card['id']}/reorder";
            sendCurlRequest($moveUrl, "PUT", $data);
        }
    }
}

So far it has worked to update the order and destination fields for the card. With this code, moving works again:

foreach ($boards as $board) {
    $url = "https://nextcloud.gnilebein.de/index.php/apps/deck/api/v1.1/boards/{$board['id']}/stacks/{$board['source']}";
    $cards = sendCurlRequest($url);

    if (!isset($cards['cards'])) {
        error_log("Fehler: Keine Karten gefunden für Board ID {$board['id']}");
        continue;
    }

    foreach ($cards['cards'] as $card) {
        if ($card['overdue'] > 1) {
            $card['order'] = 999;
            $card['stackId'] = $board['destination'];
            $moveUrl = "https://nextcloud.domain.tld/index.php/apps/deck/api/v1.1/boards/{$board['id']}/stacks/{$card['stackId']}/cards/{$card['id']}/reorder";
            sendCurlRequest($moveUrl, "PUT", $card);
        }
    }
}

gnilebein avatar Mar 19 '25 14:03 gnilebein

Hi you mentioned it changed with the "current version". Did you update to NC 31 which upgrades deck to 1.15.0?

I use that API as well and want to be on the lookout for it.

user8446 avatar Mar 20 '25 23:03 user8446

I can confirm that the behavior of the API has changed after updating Deck. Currently I am running Nextcloud 31.0.6 with Deck version 1.15.1.

I am also using the REST API to move cards. Before updating Deck (or NC respectively) moving Cards worked fine. Now I still get a "200 Success" response, but the card stays at its position.

@gnilebein Can you please explain, what you changed in your code? I think I roughly understand what you did, but am not that familiar with PHP. Mainly you are now passing indivual objects of each card to the CurlRequest instead of the common data object and you changed the order from 0 to 999. Am I missing something?

nikhub avatar Jul 07 '25 20:07 nikhub

I just updated to Deck version 1.15.2. The issue is still active. Does anybody have an idea for a workaround? Currently I am unable to use the API properly as this is a major feature of Deck.

nikhub avatar Jul 31 '25 20:07 nikhub

I am on deck v 1.15.2 as well and reordering is still working with no changes on our end.

However, we are just creating a new card in the stack and then reordering it to the top in the same stack (order=0). We are not moving it to a different stack.

Maybe that is where the issue is?

user8446 avatar Aug 01 '25 21:08 user8446

I am on deck v 1.15.2 as well and reordering is still working with no changes on our end.

However, we are just creating a new card in the stack and then reordering it to the top in the same stack (order=0). We are not moving it to a different stack.

Maybe that is where the issue is?

Sorry, I was a little imprecise. Yes, I want to move cards from one stack to another. I did not try to move cards within a stack, yet.

nikhub avatar Aug 03 '25 09:08 nikhub

The reorder-API for cards via REST is broken, as a workaround we simply used the /cards/{cardId}/reorder endpoint that the native client also uses. I have put up a PR that should fix the REST endpoint, too.

vdiezel avatar Aug 05 '25 20:08 vdiezel

I just checked, and the fixes from #7154 and friends have not resolved this issue. I run the latest beta, and even verified in the source that the changes from #7276 is applied.

I still get a 200-response, but the card is NOT moved to another stack when I use the path /apps/deck/api/v1.1/boards/{board_id}/stacks/{stack_id}/cards/{card_id}/reorder

I have tested with both the minimal parameters specified in the docs:

{
  stackId: <new id>,
  order: 1234,
}

And with the full card-config (but changing to the new stackId obviousy)

Sending the entire card-config (with the new stackId) to the endpoint /apps/deck/cards/{card_id}/reorder moves the card to the new stack as expected.

Olen avatar Nov 25 '25 14:11 Olen

I just checked, and the fixes from #7154 and friends have not resolved this issue. I run the latest beta, and even verified in the source that the changes from #7276 is applied.

I still get a 200-response, but the card is NOT moved to another stack when I use the path /apps/deck/api/v1.1/boards/{board_id}/stacks/{stack_id}/cards/{card_id}/reorder

I have tested with both the minimal parameters specified in the docs:

{
  stackId: <new id>,
  order: 1234,
}

And with the full card-config (but changing to the new stackId obviousy)

Sending the entire card-config (with the new stackId) to the endpoint /apps/deck/cards/{card_id}/reorder moves the card to the new stack as expected.

I have same problem with you, Tried many method and didnt works Please fix this or document it effectively. I wasted hours just trying to move a card.

aikusuma avatar Dec 09 '25 17:12 aikusuma