How to fix PUT request sending a 200 but not updating the page content?
Asked by Julius Thompson Admin:

Good afternoon, when trying to use PUT with Atlassian Rest API I receive a response code `200` on my request but none of the data on the page updates. I'm sending html, but have even tried to just send `Hello World` inside of the

    "body": {"storage": {"value": ""}}  

and still receive this as a response body:

```
<script>window.WRM=window.WRM||{};window.WRM._unparsedData=window.WRM._unparsedData||{};window.WRM._unparsedErrors=window.WRM._unparsedErrors||{};WRM._unparsedData["com.atlassian.plugins.atlassian-plugins-webresource-plugin:context-path.context-path"]="\"\"";WRM._unparsedData["com.atlassian.plugins.atlassian-plugins-webresource-rest:curl.cross-origin-resources"]="false";if(window.WRM._dataArrived)window.WRM._dataArrived();</script><script>window.WRM=window.WRM||{};window.WRM._unparsedData=window.WRM._unparsedData||{};window.WRM._unparsedErrors=window.WRM._unparsedErrors||{};WRM._unparsedData["_wrmBatchContents"]="{\"js\":{\"jira.heritage.critical\":[\"jira.webresources:almond\",\"com.atlassian.plugins.jquery:jquery-1.7.2\",\"com.atlassian.plugins.jquery:jquery\",\"com.atlassian.plugins.atlassian-plugins-webresource-plugin:data\",\"com.atlassian.plugins.atlassian-plugins-webresource-plugin:context-path\",\"com.atlassian.plugins.atlassian-plugins-webresource-rest:curl\",\"com.atlassian.plugins.atlassian-plugins-webresource-rest:require-handler-v2\",\"com.atlassian.plugins.atlassian-plugins-webresource-rest:web-resource-manager\",\"com.atlassian.jira.jira-spa-module:superbatch-spa-critical\",\"_context:jira.heritage.critical\"]},\"css\":{}}";if(window.WRM._dataArrived)window.WRM._dataArrived();</script>
```


Answers:
author: Vamsi Kandala
body: Hi [@Julius Thompson Admin](/t5/user/viewprofilepage/user-id/5113723),

Welcome to the community!

I gather that you are trying to update the contents of the page using REST API.

If that is the case, the general syntax is:

```
PUT /rest/api/content/{contentId}
```

Note that, to update a piece of content you must increment the 'version.number', supplying the number of the version you are creating.

Suppose if your page is currently having version 2, then use the below example to update the content of the page (should be in JSON format):

    {    "version": {        "number": 2    },    "title": "My new title",    "type": "page",    "body": {        "storage": {            "value": "<p>New page data.</p>",            "representation": "storage"        }    }}

Hope this helps.

Thanks,  
Vamsi

comments: author: Julius Thompson Admin
body: So the version number needs to match the current version number? or it needs to be incremented?

So if the current version is 2 the payload sent would needs to be:  

    "version": {        "number": 3

?


author: Vamsi Kandala
body: Hi [@Julius Thompson Admin](/t5/user/viewprofilepage/user-id/5113723)

Yes, sorry. The version number should be incremented every time you post the update and you are right.

Thanks,  
Vamsi


author: Julius Thompson Admin
body: Thank you, unfortunately that still hasn't worked.  

Currently I'm attempting to use curl and still having isuses.

I am following the steps in the documentation for making api calls here(<https://developer.atlassian.com/cloud/confluence/oauth-2-3lo-apps/>), I am able to successfully generate the authorization code and then access token. I can use that to get the cloudid as well as verify I have the correct scopes set up.

If I attempt to make a GET requests I receive a 401 unauthorized.

If I attempt to make a PUT requests I receive:

\<!DOCTYPE html\>\<html lang="en"\>\<head\>\<meta charset="utf-8"\>\<meta http-equiv="X-UA-Compatible" content="IE=edge"\>\<title\>Oops, you\&#39;ve found a dead link. - JIRA\</title\>\<link type='text/css' rel='stylesheet' href='/static-assets/metal-all.css' media='all'\>\<script src='/static-assets/metal-all.js'\>\</script\>\<meta name="decorator" content="none" /\>\</head\>\<body class=" error-page error404"\>\<script type="text/javascript"\>document.body.className += " js-enabled";\</script\>\<div id="page"\>\<header id="header" role="banner"\>\</header\>\<!-- #header --\>\<section id="content" role="main"\>\<div class="aui-page-panel"\>\<div class="aui-page-panel-inner"\>\<section class="aui-page-panel-content lowerContent"\>\<div id="error-state"\>\<span class="error-type"\>\</span\>\<h1\>Oops, you\&#39;ve found a dead link.\</h1\>\<ul\>\<li\>Go back to the \<a href="javascript\&colon;window.history.back()"\>previous page\</a\>\</li\>\<li\>Go to the \<a href="/secure/MyJiraHome.jspa"\>Home Page\</a\>\</li\>\</ul\>\</div\>\</section\>\<!-- .aui-page-panel-content --\>\</div\>\<!-- .aui-page-panel-inner --\>\</div\>\<!-- .aui-page-panel --\>\</section\>\<!-- #content --\>\<footer id="footer" role="contentinfo"\>\<section class="footer-body"\>


author: Vamsi Kandala
body: Hi [@Julius Thompson Admin](/t5/user/viewprofilepage/user-id/5113723)

The error indicates that the either the page could not be found or the authentication failed.

Can you check and make sure you are sending the correct API call?

Is it possible to post the complete url here?

Thanks,  
Vamsi


author: Julius Thompson Admin
body: Okay, I'm using the correct api call format now by using USER_EMAIL:API_TOKEN  

However, when I try to update the page with a table I get this error:

```


{"statusCode":400,"data":{"authorized":true,"valid":true,"errors":[],"successful":true},"message":"com.atlassian.confluence.api.service.exceptions.BadRequestException: Content body cannot be converted to new editor format"}
```


author: Vamsi Kandala
body: Hi [@Julius Thompson Admin](/t5/user/viewprofilepage/user-id/5113723)

Ah ok.

I think you should check this article:

<https://community.atlassian.com/t5/Confluence-questions/quot-Content-body-cannot-be-converted-to-new-editor-format-quot/qaq-p/1332071>

Let me know if it helps.

Thanks,  
Vamsi


Tags: cloud

confluence-cloud