Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How can I automatically update a Confluence page using Shell script or PYTHON

Could you please let me know

How can I automatically update a Confluence page using Shell script or PYTHON

1 answer

1 accepted

0 votes
Answer accepted
Dominic Lagger Community Leader Nov 28, 2019

Hi @Madhu 

I'm using python with the confluence REST API. And I'm using the requests package for any request.

The following script just creates a new page. With this little script, you should be able to create a script, which updates some content with this PUT request

newPageName = 'Atlassian Community'
url = 'URL'

user = 'user'
password = 'pw'

#-------------------------------------------------

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


spacekey = 'key'
parentId = parentId

mypage = {"type":"page","title":""+newPageName+"","ancestors":[{"id":parentId}],"space":{"key":""+spacekey+""},"body":{"storage":{"value":"VALUE IN STORAGE FORMAT","representation":"storage"}}}
post = requests.post(url+'/rest/api/content/', data=json.dumps(mypage), auth=auth, headers=headers, verify=False)

If you have any questions, don't hesitate to ask.

Regards, Dominic

Will this new page added on parent page or in new location?

Could you please help.

InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
warnings.warn(

 

 

This is the error which I am getting.

Dominic Lagger Community Leader Nov 28, 2019

The new page will be added at the location, where you defined with "spacekey" and "parentID". 

The parentId is the ID from the parent page, therefore, the created page is a child of that parent page. 

 

I don't know how to solve the problem correctly with the SSL, but you can suppress this warning with: 

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

Thanks alot for your help. I am new to python, thats why I am asking you like this.

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

added this too. 

hi how to update confluence page in existing table can you please help on this

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

103 views 0 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you