Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


500 internal Server Error when trying to update an attachment using Powershell

Julien Henning
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!
Nov 07, 2023

I want to update an json file in confluence using the Api and Powershell 

$pageId = "2226721108"  # Replace with the actual page ID
$attachmentId = "2238705975"  # Replace with the actual attachment ID
$apiUrl = "https://HereIsOurServer/confluence/rest/api/content/$pageId/child/attachment/$attachmentId/data"
$proxy = "ourProxy :)"

$headers = @{
    "Authorization" = "Bearer $authToken"
    "X-Atlassian-Token" = "nocheck"
$body =@{
    "file" ="StatusTestclients\JiraUpdateTestClients\result.json"

# Send the POST request to update the attachment file
Invoke-RestMethod -Uri $apiUrl -Headers $headers -Method Post -Body $body -Proxy $proxy

And here the error i get 
Invoke-RestMethod : Der Remoteserver hat einen Fehler zurückgegeben: (500) Interner Serverfehler.
In C:\Users\WAETEI1\Desktop\toolsetprelive\StatusTestclients\JiraUpdateTestClients\UpLoadDataToConfluence.ps1:19 Zeichen:1
+ Invoke-RestMethod -Uri $apiUrl -Headers $headers -Method Post -Body $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Now is the question what im doing wrong 

0 answers

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events