Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Trello api add PDF attachment will always return unsuccessful response

Jamahl M-D May 26, 2020

Hi guys,

When I upload a pdf to a Trello card. the response will always include this:
```

bytes: null,

isUpload: false,
```

as if the upload failed. But the upload actually succeeded....
This only happens when I upload a pdf

I tried to play with the mime type I used: application/pdf, x-pdf, image/png

Does anyone know how to get the API to return a successful response?

Thanks in advance!

3 answers

0 votes
Glenn
Contributor
October 12, 2020

Update:
I figured it out. The file needs to be in a form using system.io.fileinfo. 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 = [system.io.fileinfo]"C:\Path\Path\File.pdf"
}

Invoke-RestMethod -Method Post -Uri "https://api.trello.com/1/cards?$APIKEY" -Form $FORM

 

0 votes
Glenn
Contributor
September 29, 2020

I'm having the same issue using Invoke-RestMethod in PowerShell in creating a new card with a PDF attachment. If the attachment is a simple .txt it works fine. I'm guessing it has something to do with encoding. Does anyone have a code example in PowerShell with attaching anything other than a .txt to a new card?

Iain Dooley
Community Champion
September 29, 2020
Glenn
Contributor
October 1, 2020

Thanks for the tip, I posted over there and will relay the answer here if I get one

0 votes
Iain Dooley
Community Champion
May 26, 2020

@Jamahl M-D I've never been able to make file uploading work in the Trello API, I just attach links -- internally they're represented as links anyway. You might like to review the discussion here:

https://community.atlassian.com/t5/Trello-questions/Mime-types-of-attachments-uploaded-to-Trello/qaq-p/1369920#M26380

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events