Forums

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

confluence:create file list using rest api

Vidya Shevale October 22, 2018

I have existing folders and files, now I need to read that directory and create file list using same manner in confluence .

for that I need to write a script for file list and to upload an attachment.How it possible with confluence ??

reply me ASAP

 

2 answers

0 votes
Lava Kumar Dukanam _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 23, 2018

Hi @Vidya Shevale,

You could tweak this simple python script per your needs too and execute it from your current directory.


import os
import requests
URL = 'http://<confluence-server>/rest/api/content/<page-id>/child/attachment'
USERNAME = '<username>'
PASSWORD = '<password>'

for root, dirs, files in os.walk("."):
for filename in files:
with open(filename, 'rb') as f:
r
= requests.post(URL, files={filename: f}, auth=(USERNAME, PASSWORD), headers={'X-Atlassian-Token': 'no-check'})
print(r.json())

 Thanks,

Lava

0 votes
Gonchik Tsymzhitov
Community Champion
October 23, 2018

Hi! 

you can reuse this python module

https://github.com/atlassian-api/atlassian-python-api

 

Cheers,

Gonchik Tsymzhitov

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events