Deck API attachment upload via curl

I try to upload an attachment to a deck card after creating the card via API and curl.

The creation of the card works fine, but then adding the attachment does not work properly. I already found out, that the Content-Type-Header should not be set (according to the manual every call should be set to Content-Type: application/json but that seems wrong here). When I tried to put the file content and the type into a json, also the file is not handled at all.

My curl task:
/usr/bin/curl -u ‘user:pass’ -X POST -H “OCS-APIRequest: true” -H “Accept: application/json” -d ‘type=audio/mpeg’ -d ‘file=@/Users/heiko/Desktop/Interim/nickmsg_257114_f4310d25-ea53-45e6-84b9-52e4fff2826c.mp3’ ‘https://nc.xyz.de/index.php/apps/deck/api/v1.0/boards/3/stacks/7/cards/13/attachments

The result:
{“id”:null,“cardId”:13,“type”:“audio\/mpeg”,“data”:null,“lastModified”:1701065755,“createdAt”:1701065755,“createdBy”:“admin”,“deletedAt”:0,“extendedData”:}

So as it seems the server accepts the call but does not handle the file?!

Can anybody see what is wrong in the curl task and teach me how to do it right?
Or is something wrong with any setting, since the attachments are nc-files now and not dock files anymore?

Appreciate your help, thank you!

Append ?type=file to the request maybe?

https://deck.readthedocs.io/en/latest/API/#attachments

1 Like

Thank you for the solution and also for showing me, where to look for the original code, this helped a lot.
I thought I have to add the file=… into the POST-Body. I was wrong.
Great, you made my week!

1 Like