Using the api to create documents

pfuentes
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!
May 31, 2024

hey there! 

my team is trying to updload confluence documents using a python script that uses the package atlassian-python-api (version 3.41.13) all was working as expected until I tried to add a warning banner/macros that I started to get some http errors. I tried using https://confluence.atlassian.com/doc/confluence-storage-format-790796544.html (it talks about the data server version, but this is all the docs I found) and just adding a symbol  (like `<ac:emoticon ac:name="warning" />`) makes it fail with the following errors

```

requests.exceptions.HTTPError: com.atlassian.confluence.api.service.exceptions.BadRequestException: Content body cannot be converted to new editor format

```

Where can I find the correct docs or how can I achieve it? 

 

Thank you! 

1 answer

0 votes
Sadiq Satriya June 14, 2024

Hi there,

I'm not familiar with atlassian-python-api, but from the error message, it looks like the API is attempting to convert the Content body from (presumably) Storage Format into Atlas Doc Format (ADF).

The XML structure <ac:emoticon ac:name="warning" /> that you've provided is the Storage Format. On the other hand, ADF would be in a JSON format.

I would suggest explicitly specifying which Format you're using when calling the API, ie, storage or atlas_doc_format.

To help with constructing the body content when calling the REST API, you could use this free app:

Once the app is installed in Confluence, you could:

  1. Create a page.
  2. Add some content to the page, for example, a warning panel.
  3. Save the page, and view its Storage Format.

You could analyze the saved format either in "Storage" or "ADF", and use it as a sample for your API calls. One advantage of using this app is that you could even make changes directly as Storage Format or ADF, and save directly to the page.

image.png

image.png

image.png

Suggest an answer

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

Atlassian Community Events