I am using the script python script to upload an attachment into Confluence.
#!/usr/bin/python
from __future__ import with_statement
import sys, string, xmlrpclib, re, os
if len(sys.argv) < 5:
exit("Usage: " + sys.argv[0] + " spacekey pagetitle contentType filename");
spacekey = sys.argv[1];
pagetitle = sys.argv[2];
contentType = sys.argv[3];
filename = sys.argv[4];
cwd = os.getcwd() # Get the current working directory (cwd)
files = os.listdir(cwd) # Get all the files in that directory
print("Files in '%s': %s" % (cwd, files))
THIS_FOLDER = os.path.dirname(os.path.abspath(__file__))
filename = os.path.join(THIS_FOLDER, 'help_en.pdf')
with open(filename, 'rb') as f:
data = f.read(); # slurp all the data
server = xmlrpclib.ServerProxy('BaseURL');
token = server.confluence1.login('Username', 'Password');
page = server.confluence2.getPage(token, spacekey, pagetitle);
if page is None:
exit("Could not find page " + spacekey + ":" + pagetitle);
attachment = {};
attachment['fileName'] = os.path.basename(filename);
attachment['contentType'] = contentType;
server.confluence1.addAttachment(token, page['id'], attachment, xmlrpclib.Binary(data));
I am getting the following error:
xmlrpclib.Fault: <Fault 0: 'java.lang.Exception: com.atlassian.confluence.rpc.AuthenticationFailedException: Attempt to log in user failed. The maximum number of failed login attempts has been reached. Please log into the web application through the web interface to reset the number of failed login attempts.'>
Is there any solution to this and is there any other python script with different API?