Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How do i import images within html using Confluence API

Phelim McConigly June 24, 2020

Im using the confluence REST API in python.

Im importing html using:

def create_page @ atlassian.confluence

def create_page(self, space, title, body, parent_id=None, type='page',

    representation='storage'):

 

The imported html contains images. How can i upload these images (or references to them as included in the confluence page) using the REST API in python? Is it enough to change the type here to multimedia, and do something like:

import os
import requests
url = 'http://host:port/endpoint'
with open(path_img, 'rb') as img:
    name_img= os.path.basename(path_img)
    files= {'image': (name_img,img,'multipart/form-data',{'Expires': '0'}) }
    with requests.Session() as s:
        r = s.post(url,files=files)
        print(r.status_code)

1 answer

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events