500 Error when trying to update content through API rest/api/content

VADIM RAKU December 18, 2021

Hello! 

I've found some questions heree looking similar, but solutions from them didn't work, so...

I call confluence API through Postman.
URI: https://wiki.mycompany.com/rest/api/content/160172480

PUT

headers are OK, authorization basic and creds are right.

Request:

{
    "version":  {
        "number": 5
    },
    "title": "my_test_page",
    "type": "page",
    "body": {
        "storage": {
            "value": "TEST! TEST!"
        }
    }
}
Response:
{
    "statusCode": 500,
    "data": {
        "authorized": false,
        "valid": true,
        "allowedInReadOnlyMode": true,
        "errors": [],
        "successful": false
    },
    "message": "",
    "reason": "Internal Server Error"
}
I see, that authorization did't work, but why? GET responses are success even with wrong creds (anonimous read-only access). Through UI page edit work fine.

2 answers

1 accepted

1 vote
Answer accepted
Kishan Sharma
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 19, 2021

Hi @VADIM RAKU Welcome to the Atlassian Community!

Can you try below JSON body and see if that works for you

{

  "type":"page",
  "title":"my_test_page",
  "version":{"number":5},
  "space":{"key":"MySpace"},
  "body":{
    "storage":{
      "value":"<p>Some Updated Content</p>",
      "representation":"storage"
    }
  }
}
*Update your Space key, page title etc as needed.
VADIM RAKU December 19, 2021

You are a live savior! Thank you very much!!!

Like Kishan Sharma likes this
Kishan Sharma
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 20, 2021

Happy to Help 😊

0 votes
Radek Dostál
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 19, 2021

As 500 means "internal error" and as you tagged this as Server/DC instance - for these types of errors you would typically consult the applications logs (either if you have access to atlassian-confluence.log, or your admins). 500 roughly speaking should always be application-related errors, not that you would be supplying wrong parameters or payload. Almost, almost always there will be an error stacktrace thrown into the log with more details, when you happen to reproduce a 500.

VADIM RAKU December 19, 2021

As the answer at bottom says, i should send a space key as well as storage constant value. :)

OMG, Atlassian, why you haven't done an error message with 400, why 500?!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events