Query regarding custom user macro for importing MS Excel data

Ashutosh Dwivedi March 14, 2022

Hello Confluence Experts,

I have a use case wherein I need to import a MS Excel data into Confluence.

One excel row needs to be created as one new page and columns in that excel needs to mapped/linked to another existing static pages in the the same Confluence space.

By reading some Confluence docs, I got to know that I might need to create a new custom User Macro to perform this import.

Can any expert guide me further Or if someone working on similar macro help me out to do it fast?

 

Thanks in advance.

1 comment

Dominic Lagger
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.
March 14, 2022

Hi @Ashutosh Dwivedi 

You do not need a user macro for this.

What you need is a script (Python or something else) which uses the REST API from confluence to create the pages. 

All about REST API is here: https://docs.atlassian.com/ConfluenceServer/rest/7.16.2/ 

You will need the Create Content section.

Regards, Dominic

Like Ashutosh Dwivedi likes this
Ashutosh Dwivedi March 14, 2022

Hi @Dominic Lagger 

Thanks for your valuable suggestion.

Do you have any sample script calling Content creation APIs of Confluence?

If yes, that would be really great. 

 

Thanks..!!

Dominic Lagger
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.
March 14, 2022

this is a main part of creating a new page in confluence

mypage = {"type":"page","title":""+NEWPAGENAME+"","ancestors":[{"id":PARENTID}],"space":{"key":""+SPACEKEY+""},"body":{"storage":{"value":"" + PAGE_IN_STORAGE_FORMAT+ "", "representation": "storage"}}}
post = requests.post(url+'/rest/api/content/', data=json.dumps(mypage), auth=auth, headers=headers, verify=False)
newpageId = json.loads(post.text)['id']

You need auth and headers:

headers = {
'X-Atlassian-Token': 'no-check',
'Content-Type': 'application/json'
}
auth=(user, password)

This is written in python

Regards, Dominic

Like Ashutosh Dwivedi likes this

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events