I would like to add images to confluence pages. What I am trying is this:
filename = 'images/conc_v_input.png'
image = '<ac:image ac:title="ConcVInput" ac:alt="concvinput" ac:height="400"><ri:attachment ri:filename="images/conc_v_input.png" ri:version-at-save="3" /></ac:image>'
confluence.append_page(my_page, my_title, image, parent_id=unit_test_analysis,
type='page', representation='storage', minor_edit=False)
What I get is Unknown Attachment with the hover text of 'images/conc_v_input.png'
Any way to sort this out?
It looks like if you upload the image first, then you can reference it and show it on the page.
<ac:image>
<ri:attachment ri:filename=
"tb.png" />
</ac:image>
This was helpful, but seems like you might already know of it. I used the images section.
https://confluence.atlassian.com/doc/confluence-storage-format-790796544.html
The file name is the name of the attachment you uploaded.
This actually worked! it was slightly different from what I had tried before. Thank you!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've been trying for a while to make this work. I have a confluence page and can add attachments to it via python program and REST API. This is vanilla, similar to many other examples online.
The basic code that always returns 409 is:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Katie,
If I understand correctly, you're using the Python API module to try to add an image attachment to an existing page. The unknown attachment would seem to indicate that Confluence doesn't have this image added yet.
Looking into what I believe is the documentation for that API over in https://atlassian-python-api.readthedocs.io/confluence.html I think that we need to make sure Confluence knows of this attachment first.
# Attach (upload) a file to a page, if it exists it will update the # automatically version the new file and keep the old one confluence.attach_file(filename, name=None, content_type=None, page_id=None, title=None, space=None, comment=None)
Try that first. This should then allow that page in Confluence to use that image.
Let me know if this helps.
Andy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry that didn't work. It was also one of the things I had tried before. The figure doesn't appear in the page at all either. If it were attached, shouldn't it be on the page?
Thanks for trying.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Confluence handles attachments a little differently than say Jira does. Just because an attachment is connected to a page, does not necessarily mean it appears on that page automatically. If you're looking at this page in Confluence Cloud, click the ellipsis (...) menu on the top right of the page and go to Attachments. This will show what files are attached to that page. The URL tends look like
/wiki/pages/viewpageattachments.action?pageId=600581878
Try checking this after making that attach call. I'm interested learn if perhaps some form of your image is displayed there or not first. If there is an entry for your attachment, I'd be curious to see if it displays on this page of Attachments or if the image is somehow corrupted.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for the info about where the file is attached. the image is attached (I can see the file, and click on it and it is the correct one).
The image is not corrupted, and it looks perfect.
Any suggestions about the next step?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I noticed that in my own Confluence Cloud site, that uploading a filename with a '/' character is replacing that character with a ':' instead. This could be a factor here in regards to the way you are referring to that file.
Once the file is uploaded to the page, see if you can then refer to it by the filename of
images:conc_v_input.png
instead of
images/conc_v_input.png
This is likely why Confluence does not understand the filename you are telling it to append to that page. Try that and let me know if that helps.
Andy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.