Skip to content

Problems while using attach_file method in confluence #1442

@jbtescudeiro16

Description

@jbtescudeiro16

Recently, I had to create some pages on confluence using a python script. Two pages contain Images. The first time that I attach the image to the page, there's no problem, but when I try and create again the pages and attach files with the same name, it gives me an error. I was expecting that uploading an image with an existing name, a new revision of the image would be created, but that doesn't seems the case.
The version i'm using is :
atlassian-python-api v1.41.14

The error is :
Error while conecting to Confluence org.springframework.transaction.UnexpectedRollbackException: Transaction rolled back because it has been marked as rollback-only

The code i'm using is :

for filename in os.listdir("OutputMD/"):
       file_path = os.path.join("OutputMD/", filename)
       MD_content = read_file_content(file_path)
       page_title = os.path.splitext(filename)[0]
       newpagestats= confluence.update_or_create(page_id, page_title, MD_content, representation='wiki',editor='v2', full_width=True)
       print(newpagestats["id"])
       if page_title in aux_dict:
           for i in aux_dict[page_title]:
               print("Attach files trying")
               confluence.attach_file("Photos/" + i, name=i, content_type=None, page_id=newpagestats["id"], title=page_title,space=None, comment=None)
       print("Page "+ page_title + " created!")
   print("Pages Created!")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions