Reputation: 6907
I am trying to migrate some existing blog entries into our confluence wiki using XML-RPC with Python. It is currently working with such things as title, content, space etc but will not work for created date.
This is what was currently attempted
import xmlrpclib
proxy=xmlrpclib.ServerProxy('<my_confluence>/rpc/xmlrpc')
token=proxy.confluence1.login('username', 'password')
page = {
'title':'myTitle',
'content':'My Content',
'space':'myspace',
'created':sometime
}
proxy.confluence1.storePage(token, page)
sometime
is the date I want to set to a time in the past. I have tried using Date objects, various string formats and even the date object returned by a previous save, but no luck.
Upvotes: 1
Views: 1168
Reputation: 148
If you would try to store the existing content as actual blog entries in Confluence, then you could use the "publishDate" parameter:
import xmlrpclib
import datetime
proxy=xmlrpclib.ServerProxy('<my_confluence>/rpc/xmlrpc')
token=proxy.confluence1.login('username', 'password')
blogpost = {
'title' : 'myTitle',
'content' : 'My Content',
'space' : 'myspace',
'publishDate' : datetime.datetime(2001, 11, 21, 16, 30)
}
proxy.confluence1.storeBlogEntry(token, blogpost)
The XML-API for pages ignores the "created" parameter.
Upvotes: 1
Reputation: 161
You can use strptime
because type will not match directly. Hope this works.
new_sometime = datetime.strptime(sometime, '%Y-%m-%d')
page = {
'title':'myTitle',
'content':'My Content',
'space':'myspace',
'created':new_sometime
}
Upvotes: 0