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?
The error which is given is pretty clear I think.
You have tried and failed to login too much. Do you have the possibility to login to the web application and reset the failed login attempts?
I tried login to the web application and it was successful.
But now I am getting
Traceback (most recent call last):
page = server.confluence2.getPage(token, spacekey, pagetitle);
xmlrpclib.Fault: <Fault 0: "java.lang.Exception: com.atlassian.confluence.rpc.RemoteException: You're not allowed to view that page, or it does not exist.">
I have defined the token, spacekey and pagetitle.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
First, I like that you were successful to login.
To the second error you get. For me, it seems to be a permission thing. Perhaps you do not have the permission to view this page. On the other hand, it might be a special key in the pagetitle.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.