Created
October 6, 2014 04:28
-
-
Save marshyski/7de895ee498776d1f713 to your computer and use it in GitHub Desktop.
Create page and attach file under a confluence wiki site with Python Suds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# yum install python-suds | |
import suds | |
import base64 | |
# Uncomment the logging if you want to see the XML input and output for debugging | |
import logging | |
import logging.handlers | |
# Turn on logging | |
logging.basicConfig(level=logging.INFO) | |
logger = logging.getLogger('suds.client') | |
# Setup logging to file | |
logger.setLevel(logging.DEBUG) | |
url = 'http://wiki.finra.org/confluence/rpc/soap-axis/confluenceservice-v2?wsdl' | |
client = suds.client.Client(url) | |
# Get the session token | |
sessionId = client.service.login(in0 = 'john-username-goes-here', # USER | |
in1 = 'john-password-goes-here') # PW | |
# Load Confluence bean:RemoteAttachment namespace | |
attachns = '{http://beans.soap.rpc.confluence.atlassian.com}RemoteAttachment' | |
remoteAttachment = client.factory.create(attachns) | |
remoteAttachment.comment = '' | |
# Confluence will complain if content type is blank | |
remoteAttachment.contentType = 'text' | |
remoteAttachment.creator = 'john@email-account.com' | |
remoteAttachment.fileName = 'file-you-want-to-attach-here.txt' | |
remoteAttachment.title = '' | |
remoteAttachment.fileSize = 0 | |
remoteAttachment.id = 0 | |
remoteAttachment.pageId = 0 | |
fileData = base64.b64encode("Some test data 1") | |
result = client.service.addAttachment(in0 = sessionId, | |
# Page ID for test page on Wiki site | |
in1 = 464388444, | |
in2 = remoteAttachment, | |
in3 = fileData | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment