Unable to post "Content body cannot be converted to new editor format"

Hi,

I wrote a python script that posts a table from an SQL query to confluence. It then PUT/POSTS Things have worked for the last year, but today, I’m running into an error. I can only see the header of my table, not the data inside.

This is the error:
{“statusCode”:400,“data”:{“authorized”:false,“valid”:true,“errors”:,“successful”:false},“message”:“com.atlassian.confluence.api.service.exceptions.BadRequestException: Content body cannot be converted to new editor format”}

I’ve been having trouble figuring out what this means. What is wrong with my request?

Thanks

Hi
What are you trying to POST as a storage?

May be related to this one (not really an answer, but something to consider) - A page created via API is not displayed with error "This editor does not support displaying this content"

Looks like it does depend on what you POST and probably you can find some similarities to understand the possible reason

Alex

Hello Armand,

questions like this are always hard to answer, especially because the most valuable information is missing, e.g.

  • Which api are you using?
  • How does your request look like?
  • Which parameters do you pass?
  • What does the body / content look like?

A question like this is best answered when all these information are available. It can even be improved further by including a working example code of your problem, so others can immediately reproduce the behavior.

Best regards,
Robert

1 Like

Hi All,

Thank you for your responses. This is the code I’m using. It’s running a POST because this page already exists. This is the code I’m using.

        payload['id'] = page_id
        payload['type'] = "page"
        payload['space'] = {'key' : self.configuration['confluence_space']}
        payload['body'] = dict()
        payload['title'] = title
        payload['body']['storage'] = dict()
        payload['body']['storage']['value'] = html
        payload['body']['storage']['representation'] = "storage"
        if title:
            payload['version'] = {'number' : str(int(version) + 1)}
        headers = {'content-type': 'application/json'}
        if title:
            response = requests.put(self.configuration['confluence_host'] + '/wiki/rest/api/content/' + page_id, auth=HTTPBasicAuth(self.configuration['confluence_user'], self.configuration['confluence_password']), data=json.dumps(payload), headers=headers)
        else:
            response = requests.post(self.configuration['confluence_host'] + '/wiki/rest/api/content', auth=HTTPBasicAuth(self.configuration['confluence_user'], self.configuration['confluence_password']), data=json.dumps(payload), headers=headers)
        if response.status_code != 200:
            ACLogger().get_logger().info(html)
            ACLogger().get_logger().error(response.text)

I’m attempting to post this html:

 <p /><table> 
 <tr><th>row_number</th><th>type</th><th>description</th><th>schema</th><th>table</th><th>columns</th><th>input_parameters</th><th>status</th><th>errors</th><th>error_data</th><th>test_time</th><th>result_query</th> 
 </tr> 
 <tr><td>1</td><td>WINDOW MATCH</td><td>BMS Luspatercept Shipments Previous Build check</td><td>reblozyl_build,reblozyl</td><td>raw_beghou_bms_luspatercept_shipments_history</td><td>order_number</td><td><p>p_window_<b>_column = ORDERED_DATE, p_window_days = 7, p_mode = same, </b>, </p></td><td><p style = "color: maroon;" ><b>Error</b></p></td><td>None</td><td>None</td><td>2021-10-15</td><td>Table reblozyl_build,reblozyl.raw_beghou_bms_luspatercept_shipments_history or columns ORDER_NUMBER do not exist.</td> 
 </tr> 
 <tr><td>2</td><td>WINDOW MATCH</td><td>Raw 867 File Check with Previous Build</td><td>reblozyl_build,reblozyl</td><td>raw_beghou_sd_luspatercept_867_history</td><td>reporting_date,invoice_no,ndc_upc</td><td><p>p_window_<b>_column = Reporting_Date, p_window_days = 7, p_mode = same, </b>, </p></td><td><p style = "color: maroon;" ><b>Error</b></p></td><td>None</td><td>None</td><td>2021-10-15</td><td>Table reblozyl_build,reblozyl.raw_beghou_sd_luspatercept_867_history or columns Reporting_Date,Invoice_No,NDC_UPC do not exist.</td> 
 </tr> 
 <tr><td>3</td><td>CONDITION CHECK</td><td>Invalid NDC Check</td><td>reblozyl</td><td>raw_beghou_bms_luspatercept_returns</td><td>cross_reference</td><td><p>p_conditi<b>ion = cross_reference NOT IN (&apos;59572071101&apos;, &apos;59572077501&apos;), </b>, </p></td><td><p style = "color: red;"   ><b>Fail</b></p></td><td>1</td><td><p>cross_reference<br/>59572071101</p></td><td>2021-10-15</td><td>select count(1) from (select distinct cross_reference from reblozyl.raw_beghou_bms_luspatercept_returns where not (cross_reference NOT IN ('59572071101', '59572077501')))</td> 
 </tr> 
 <tr><td>4</td><td>CONDITION CHECK</td><td>Raw 867 Returns Sample File Check</td><td>reblozyl</td><td>raw_beghou_bms_luspatercept_returns_history</td><td>file_date</td><td><p>p_conditi<b>ion = file_date &lt; &apos;2021-07-01&apos;, </b>, </p></td><td><p style = "color: red;"   ><b>Fail</b></p></td><td>10</td><td><p>file_date<br/>2021-08-09<br/>2021-08-16<br/>2021-08-23<br/>2021-08-30<br/>2021-09-07<br/>2021-09-13<br/>2021-09-20<br/>2021-09-27<br/>2021-10-04<br/>2021-10-11</p></td><td>2021-10-15</td><td>select count(1) from (select distinct file_date from reblozyl.raw_beghou_bms_luspatercept_returns_history where not (file_date < '2021-07-01'))</td> 
 </tr> 
 <tr><td>5</td><td>CONDITION CHECK</td><td>BMS Luspatercept Shipments History Sample File Data</td><td>reblozyl</td><td>raw_beghou_bms_luspatercept_shipments_checks</td><td>error_reason</td><td><p>p_conditi<b>ion = error_reason = &apos;Sample File Data&apos;, </b>, </p></td><td><p style = "color: green;" ><b>Success</b></p></td><td>0</td><td>None</td><td>2021-10-15</td><td>None</td> 
 </tr> 
 <tr><td>6</td><td>NOT NULL</td><td>NOT NULL TEST for NDC Code</td><td>reblozyl</td><td>raw_beghou_bms_luspatercept_returns</td><td>cross_reference</td><td><p><b>, </b>, </p></td><td><p style = "color: green;" ><b>Success</b></p></td><td>0</td><td>None</td><td>2021-10-15</td><td>None</td> 
 </tr> 
 <tr><td>7</td><td>PRIMARY KEY</td><td>Primary Key test for Raw 867 File</td><td>reblozyl</td><td>raw_beghou_sd_luspatercept_867</td><td>invoice_no,ndc_upc,reporting_date</td><td><p>p_mode = <b> NOT NULL, </b>p_subset_condition: <b> reporting_date &gt;= &apos;2021-07-01&apos;</b>, </p></td><td><p style = "color: green;" ><b>Success</b></p></td><td>0</td><td>None</td><td>2021-10-15</td><td>None</td> 
 </tr> 
 <tr><td>8</td><td>PRIMARY KEY</td><td>Primary Key test for Raw 867 File</td><td>reblozyl</td><td>raw_beghou_sd_luspatercept_867</td><td>invoice_no,ndc_upc,reporting_date</td><td><p>p_mode = <b> UNIQUENESS, </b>p_subset_condition: <b> reporting_date &gt;= &apos;2021-07-01&apos;</b>, </p></td><td><p style = "color: green;" ><b>Success</b></p></td><td>0</td><td>None</td><td>2021-10-15</td><td>None</td> 
 </tr> 
 <tr><td>9</td><td>PRIMARY KEY</td><td>Primary Key Test for BMS 867 Exclusion List</td><td>reblozyl</td><td>raw_bms_867_exclusion_list</td><td>invoice_no,ndc_upc</td><td><p>p_mode = <b> NOT NULL, </b>, </p></td><td><p style = "color: green;" ><b>Success</b></p></td><td>0</td><td>None</td><td>2021-10-15</td><td>None</td> 
 </tr> 
 <tr><td>10</td><td>PRIMARY KEY</td><td>Primary Key Test for BMS 867 Exclusion List</td><td>reblozyl</td><td>raw_bms_867_exclusion_list</td><td>invoice_no,ndc_upc</td><td><p>p_mode = <b> UNIQUENESS, </b>, </p></td><td><p style = "color: green;" ><b>Success</b></p></td><td>0</td><td>None</td><td>2021-10-15</td><td>None</td> 
 </tr> 
 </table> 

Hi

I think you need to escape this part

(file_date < '2021-07-01'))

to be

(file_date &lt; '2021-07-01'))

So, the document you post will be valid xHTML
Alex

Thanks,
That resolved the issue.