Update content API - Not working

Søren Dahl Poulsen
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 16, 2022

Hi all! 

I am attempting to update the content of a page using REST api. 

I am calling this endpoint using PUT: http://domain/wiki/rest/api/content/3906240556

With this payload: 

{

    "id"3906240556,

    "type""page",

    "space": {

        "key""PK"

    },

    "body": {

        "title""NEW TITLE",

        "storage": {

            "value""test test test",

            "representation""storage"

        }

    },

    "version": {

        "number"5

    }

}

I get a response "200 OK", but nothing is actually updated on the page itself. I can't figure out why that is. Does anyone have any pointers as to what might be the issue? 

1 answer

1 accepted

0 votes
Answer accepted
Jessica
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 5, 2022

Hi @Søren Dahl Poulsen 

Welcome to the Atlassian Community!

I have tried the same endpoint you used, but if my title is inside the body for example, it doesn't allow me to update and there is no 200 OK for me.
I'm following this documentation REST API - Update comment

So, I'd like to ask you to test running something like this, when trying to update the page:

 {
"version": {
"number": 5
},
"type": "page",
"status": "current",
"title": "NEW TITLE",
"space": {
"key": "PK"
},
"body": {
"storage": {
"value": "test test test",
"representation": "storage"
}
}
}

That should do the trick!

If that still doesn't work, would you mind sharing the body response?
Also, keep in mind to use https:// instead of http:// :)

Cheers,
Jessica

Daniel Schmidt July 6, 2022

Hi Jessica

I am fighting with the same problem like @Søren Dahl Poulsen

The title will be updated, but the value (page content) is not changing?

Could you please check again on your side.

Here is my Body:

{
"version": {
"number": 11
},
"type": "page",
"status": "current",
"title": "New page update by API",

"storage": {
"value": "test daniel",
"representation": "storage"
}
}

The value has no function?

BR

Daniel 

Jessica
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 6, 2022

Hi @Daniel Schmidt 

The value has function and I can confirm to you it works, but in your case, it seems it is not really inside the body, like in the example above or in the REST API - Update comment documentation examples, so this seems what is going wrong there.

From what I can see, the storage and value, should be after the body, which there isn't any in your example.

Could you try this one?

{
"version": {
"number": 12
},
"title": "New page update by API",
"type": "page",
"body": {
"storage": {
"value": "test daniel",
"representation": "storage"
}
},
}

Hope this helps.
Jessica

Søren Dahl Poulsen
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!
July 11, 2022

@Jessica Moving title outside of body and adding using "https" did the trick for me. Thanks! 

Like Jessica likes this
Daniel Schmidt July 12, 2022

Hi @Jessica 

Sorry for my late reply to you.

Your JSON format is working fine for me.

Thanks!

BR Daniel

{
"version": {
"number": 12
},
"title": "New page update by API",
"type": "page",
"body": {
"storage": {
"value": "test daniel",
"representation": "storage"
}
},
}
Like Jessica likes this
Tommy Grealy
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!
April 16, 2024

Hi I am still having a similar issue.

https://wiki.mydomain.com/rest/api/content/1234567

(1234567 represents the content-id) 

Using the almost the exact structure above does not post any update to my page. For the "value" - I am actually posting a html string but that is really the only difference. Because it's html - I don't use "storage", instead I use "view" (as directed by the meaning of these different params that are allowable documented here

{
    "version": {
        "number": 4
    },
    "title": "TEST PAGE ONLY V3",
    "type": "page",
    "body": {
        "view":{
            "value": "<h1>Test only - will revert</h1>",
            "representation": "view"
        }
    }
}



Only if I actually change both version number (increment it by 1) and the TITLE to something new - will it actually create a new page version. Otherwise, nothing happens at all to the page even though I am getting a 200 response to my API call.

I have a couple of questions:

Why do we have a node called "storage" and inside that node we have a key called "representation" who's value is also "storage" - is this not already implied by the top-level node name?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events