Forums

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

Getting 415 error when uploading csv file via powershell

John Welch
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 12, 2023

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
When I run that script, I get a 415 error:
Invoke-RestMethod : The remote server returned an error: (415) 415.
if I try to use Put instead of Post, I get a 405, method not allowed. 
it's definitely a CSV file i'm uploading, so I'm a bit mystified here, any help would be greatly appreciated.

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events