Forums

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

How to fix PUT request sending a 200 but not updating the page content?

Julius Thompson Admin January 4, 2023

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>

1 answer

0 votes
Vamsi Kandala
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.
January 4, 2023

Hi @Julius Thompson Admin,

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

Julius Thompson Admin January 5, 2023

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

 ?

Vamsi Kandala
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.
January 5, 2023

Hi @Julius Thompson Admin

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

Thanks,
Vamsi

Julius Thompson Admin January 5, 2023

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">

Vamsi Kandala
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.
January 5, 2023

Hi @Julius Thompson Admin

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

Julius Thompson Admin January 6, 2023

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"}
Vamsi Kandala
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.
January 6, 2023

Suggest an answer

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

Atlassian Community Events