Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct way to add PDF attachments by file in New-TrelloCard #22

Open
user8446 opened this issue Sep 28, 2020 · 0 comments
Open

Correct way to add PDF attachments by file in New-TrelloCard #22

user8446 opened this issue Sep 28, 2020 · 0 comments

Comments

@user8446
Copy link

user8446 commented Sep 28, 2020

Hi Adam,

I have tried -fileSource "C:Path\Path\File.pdf"

and

$File = Get-Item -Path "C:Path\Path\File.pdf"
-fileSource $File

and

$File = [IO.File]::ReadAllBytes("C:Path\Path\File.pdf")
-fileSource $File

and

added 'ContentType' = 'multipart/form-data' to the $RestParams for the Invoke-RestMethod API call.

None work. Removing -fileSource allows the new card to be created. What is the correct way or syntax to add an attachment via New-TrelloCard?
My guess is this has something to do with the encoding as Add-TrelloCardAttachment works fine with .txt but fails with PDF

Update:
I figured it out doing the API call direct. 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
@user8446 user8446 changed the title [Feature Request] Attachments in New-TrelloCard Correct way to add attachments by file in New-TrelloCard Sep 28, 2020
@user8446 user8446 changed the title Correct way to add attachments by file in New-TrelloCard Correct way to add PDF attachments by file in New-TrelloCard Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant