Adding card to deck using script

I’m looking at using Nextcloud Flow to automatically add a Card to a deck/stack when a file is tagged.
From what I can find, the only way to do that would be to create a script that is run when a file is tagged. Unfortunately I have limited-to-no programming knowledge but willing to learn.

Is this something that could be done?

Robert

I think it can be achieved by quering the Deck API through cURL. It is quite well documented. If board and stack ID are known and always the same, it shouldn’t be too hard.

I will test it myself and post some example commands here.

I think a flow integration would definitiely be interesting. Could you describe your use case a bit more in detail, especially what the newly created card should contain, assuming you have the file as input data.

1 Like

My use case is for an Architectural firm. So for example, Construction manager sends a request for information (RFI) pdf via email, the RFI.pdf is saved in the Project/RFI folder on Nextcloud with “RFI & Review” tags added. This then automatically adds a card under Project Deck/Todo Stack with a link to the RFI.pdf in question.

Here are the promised command examples:

Overview of boards an their corresponding IDs

  • curl -u username:password 'https://cloud.example.com/index.php/apps/deck/api/v1.0/boards' -H "OCS-APIRequest: true" | json_pp | grep -e 'boardId' -e 'title' | uniq

If you don’t have json_pp installed, you can omit it, but the output won’t be pretty. Applies to uniq, too.

List all stacks contained in the selected board

  • curl -u username:password 'https://cloud.example.com/index.php/apps/deck/api/v1.0/boards/{boardId}/stacks' -H "OCS-APIRequest: true" | json_pp | grep -e 'stackId' -e '^[[:space:]]\{6\}"title' | uniq

(set a number from the results list of the previous command for {boardId})

Now that you know board ID and stack ID, you can create a new card in the selected board/stack

  • curl -X POST -u username:password 'https://cloud.example.com/index.php/apps/deck/api/v1.0/boards/{boardId}/stacks/{stackId}/cards' -d 'title=Card title goes here' -H "OCS-APIRequest: true"

The ID of the newly created card is returned to you upon creation "Id":xxx

{"title":"Card title goes here","description":"","stackId":297,"type":"plain","lastModified":1583590242,"lastEditor":null,"createdAt":1583590242,"labels":null,"assignedUsers":null,"attachments":null,"attachmentCount":null,"owner":"testuser","order":999,"archived":false,"duedate":null,"deletedAt":0,"commentsUnread":0,"id":871,"overdue":0}

Assigning a label

  • curl -X PUT -u username:password 'https://cloud.example.com/index.php/apps/deck/api/v1.0/boards/{boardId}/stacks/{stackId}/cards/{cardId}/assignLabel' -d 'labelId={labelId}' -H "OCS-APIRequest: true"

Obtaining the lableId

I couldn’t find a simple way to query a list of all labels available within a board.
EDIT: The labels are returned here:

  • curl -u username:password 'https://cloud.example.com/index.php/apps/deck/api/v1.0/boards/{boardId}

-OR-

  • Access Nextcloud’s database and find the ID in the deck_labels table
1 Like

Wow ok, thanks for all your work. Its a little overwhelming but great. This helps a lot

1 Like