As the title says, I have a powershell script:
#boilerplate to display a file chooser dialog
Add-Type -AssemblyName System.Windows.Forms
$fileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{
#InitialDirectory = [Environment]::GetFolderPath('Desktop')
RestoreDirectory = $true
Multiselect = $false
ShowHelp = $false
}
#display the file browser so i can pick the file I want
$null = $fileBrowser.ShowDialog()
#set filepath to var
$attachmentPath = $fileBrowser.FileName
#set content type
$content="text/csv"
#auth header for confluence using PAT
$headers = @{'Authorization'="Bearer <PAT Token here>"
'X-Atlassian-Token'="no-check"}
#page URL
$theURL = "https://<domain>/rest/api/content/<page ID>/child/attachment"
#post command
Invoke-RestMethod -Headers $headers -Uri $theURL -Method Post -InFile $attachmentPath -ContentType $content
Invoke-RestMethod : The remote server returned an error: (415) 415.