I'm looking at the docs: http://docs.atlassian.com/atlassian-confluence/latest/com/atlassian/confluence/rpc/soap/XhtmlSoapService.html#addProfilePicture(java.lang.String, java.lang.String, java.lang.String, java.lang.String, byte)
and I am able to login. Now I am trying to add a profile picture (I do have permissions) and the code looks like this:
with open('C:/roster/face.png', 'rb') as p:
pic = p.read()
server.confluence1.addProfilePicture( token, userName, 'face.png', 'image/png', pic )
And the (truncated for brevity) error I get is:
File "R:\Tools\Python\2.6\lib\xmlrpclib.py", line 604, in close
self._parser.Parse("", 1) # end of data
ExpatError: no element found: line 1, column 0
What am I doing wrong? I know my token and userName are correct. There isn't much direction for the mime type but it looks like that's all it expects. I hope the docs get more examples.
The following script works for me:
#!/usr/bin/python import xmlrpclib """ create a proxy object with methods that can be used to invoke corresponding RPC calls on the remote server """ server = xmlrpclib.ServerProxy('http://path.to.your.confluence/rpc/xmlrpc') try: """ log in a user Returns a String authentication token to be passed as authentication to all other remote calls. It's not bulletproof auth, but it will do for now. Must be called before any other method in a 'remote conversation'. From 1.3 onwards, you can supply an empty string as the token to be treated as being the anonymous user. """ token = server.confluence1.login('username', 'password'); """ add profile picture Read a file and add it as new profile picture to specified user """ pictureData = xmlrpclib.Binary(open('/path/to/avatar.png').read()) profilePictureAdded = server.confluence1.addProfilePicture(token, 'username', 'avatar.png', 'image/png', pictureData) if profilePictureAdded: print "Successfully added new profile picture..." else: print "Failed to add new profile picture..." except xmlrpclib.Fault, err: print "Fault code: %d" % err.faultCode print "Fault string: %s" % err.faultString
Hope this helps
Do you use templates with Confluence? Take part in a remote 1-hr workshop. You'll receive USD $100 for your time! We're looking for people to participate in a remote 1-hr workshop...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs