After I delete an attachment via REST API, when I upload the same attachment via API, the request is successful - I get a 200 response code. However, there is no data in the attachment and it cannot be previewed. Any any idea why this is happening?
def upload_image(file, fb, parentID, url, data, auth, files, headers):
print("hello")
r = requests.post(url, data=data, auth=auth, files=files, headers=headers)
if r==200:
return r
elif r.status_code==400:
print("the image exists. updating the image")
imgid, version = get_attachment_id(file, parentID)
urld = base+imgid
r2 = requests.delete(urld, auth=auth)
r2 = upload_image(file, fb, parentID, url, data, auth, files, headers)
return r2
the attachments on the page:
Hello there!
As I understand, attachment upload is not working as expected with your Confluence instance.Is that correct Antony?
Thanks for sharing part of your code with us! However, we still need to look into the cURL string you are sending to Connie. It should look like this:
curl -D- -u admin:admin -X POST -H "X-Atlassian-Token: nocheck" -F "file=@myfile.txt" -F "comment=This is my File" http://myhost/rest/api/content/123/child/attachment
If you send us your cURL string, be careful not to disclose any sensitive information. Community is an open space and anyone can see it here!
With the limited access we have to your code, it is hard to determine what might be wrongly converted or returned, if that is the root cause.
You can have a deeper look at our create attachment procedure via REST here:
Looking forward to your reply Antony!
@Diego my code for creating the page and uploading images to the page works fine. I also figured out how to update the attachments. However, I do not want to keep updating the attachments since that creates multiple versions of each attachment. So in my code, I check if a particular attachment exists. If it exists, I delete the attachment and then try to upload the updated attachment. After I delete the attachment, my code for creating the attachment works. However, as shown in the image, the attachment files lose data and cannot be previewed - after deleting the attachment, when I upload the attachment their size is 0.0 kb.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.