I was successful in creating a new page and in posting to the blog in my personal space thanks to some info here. Python comes with everything needed to use the interface. An example script consists of these parts:
Now you can use many of the API functions. For instance you can create a page:
where "newpagedata" is a dictionary that has at a minimum the keys "title", "content", and "space". You can also update an existing page by getting a reference of it and replacing the content.
The same process works basically the same way for blog posts, except the functions are "storeBlogEntry" and "getBlogEntry" if you know the ID, or "getBlogEntryByDayAndTitle" if you know that.
Many more functions are available at the link above.
from xmlrpclib import Server s = Server("https://server/rpc/xmlrpc") token = s.confluence1.login("user", "password")
newpagedata = {"title":"Python example New Page 2","content":content,"space":"spacekey"} newpage = s.confluence1.storePage(token, newpagedata)
page = s.confluence1.getPage(token, "spacekey", "Python example New Page") page["content"] = "Updated text" page = s.confluence1.storePage(token, page)
Many more functions are available at the link above.
No comments:
Post a Comment