Forums

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

BAD Request 400 when trying to update confluence content through API

JiraAdminTest September 26, 2022

I am trying to update a page using the Rest API and powershell in confluence

I am able to pull the page and data using:

Invoke-WebRequest https://myconfluence.com/rest/api/content/<page_id> -Header @{Authorization = 'Bearer <'mytoken'>}

 

To update the page, this is what I'm trying but I keep getting The remote server returned an error: (400) Bad Request.

Invoke-WebRequest -Method 'PUT' https://myconfluence/rest/api/content/<page_id> -UseBasicParsing -Header @{Authorization = 'Bearer <mytoken>' ; "Content-Type" = "application/json" } -Body '{ "status":"current", "version":{"number": 2}, "type": "page", "title":"existing_title", "body":{"storage":{"value":"<html> <head></head> <body> <p class=\"auto-cursor-target\"><br></p> <table class=\"wrapped\"> <colgroup> <col> <col> <col> <col> </colgroup> <tbody> <tr> <th>Col1</th> <th>Col2</th> <th colspan=\"1\">Col3</th> <th colspan=\"1\">Col4</th> </tr> <tr> <td>V1</td> <td>V2</td> <td colspan=\"1\">N/A</td> <td colspan=\"1\">N/A</td> </tr> <tr> <td>Q1</td> <td>N/A</td> <td colspan=\"1\">N/A</td> <td colspan=\"1\">N/A</td> </tr> </tbody> </table> <p class=\"auto-cursor-target\"><br></p> </body></html>", "representation":"storage"}}}'

1 answer

1 accepted

2 votes
Answer accepted
JiraAdminTest September 26, 2022

I found my problem

representation should be set to: "editor"

Deepak Kumar
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!
January 29, 2024

@JiraAdminTest @Can you please explain it clearly 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events