Attaching PDF attachments fail in the API POST call


This is for both creating a attachment on an existing card as well as with creating a new card.
However, if the attachment is a TXT file, the attachment is created so the call is being made properly. I’m guessing that a PDF has to be encoded but there is nothing in the docs that says that.

What would be the correct way to attach a PDF via the API?

I’m making the call in PowerShell, but I can also use cURL.

Thank you in advance.

Two things I’d recommend checking out.

First, this project that has a lot of examples on how to attach stuff via the API:

Second, I’d recommend following whatever the Trello web client does. To do so, open your browser’s console and watch the network as you attach a .pdf to a card.

Thank you for the tip. However the glitch project and the web GUI is only for adding attachments to an existing card. I would like to create a new card with an attachment via the API which is where I am struggling with because of limited documentation:

The docs only say:


Format: binary

I figured it out. The file needs to be in a form using . I’m on PowerShell 7 and I believe you might have to get into some .NET to make it work on PS5.1.

$FORM = @{
    idList     = "xxxxxx"
    pos        = "top"
    name       = "TestTest"
    fileSource = []"C:\Path\Path\File.pdf"

Invoke-RestMethod -Method Post -Uri "$APIKEY" -Form $FORM