The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

TAGS
AUG Leaders

Atlassian Community Events