Skip to content

Instantly share code, notes, and snippets.

@jmcmellen
Created March 19, 2010 20:15
Show Gist options
  • Save jmcmellen/338123 to your computer and use it in GitHub Desktop.
Save jmcmellen/338123 to your computer and use it in GitHub Desktop.
#Create, update and blog post into a Confluence Wiki with Python. You'll have to
#provide the server and user credentials
import sys
from xmlrpclib import Server
user = "username"
passwd = "passwd"
serverurl = "https://server.example.com/rpc/xmlrpc"
spacekey = "demospace"
s = Server( serverurl )
token = s.confluence1.login( user, passwd )
#Create a new page
newpagedata = {"title":"My Python example page", "content":"The page's contents",
"space":spacekey}
newpage = s.confluence1.storePage(token, newpagedata)
#Get a page by title and update it
existingpage = s.confluence1.getPage(token, spacekey, "My Python example page")
existingpage["content"] = page["content"] + "\nUpdating the page with new text"
existingpage = s.confluence1.storePage(token, existingpage)
#Make a new blog post
newblogpostdata = {"title":"Blogging from outside - Python",
"content":"If you're seeing this, I was successful in posting a blog entry from an external Python script. Yay!",
"space":spacekey}
newblogpostdata = s.confluence1.storeBlogEntry(token, newblogpostdata)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment