Example: Authenticate user and create node using Services 3.0 XML-RPC and Python
Last updated on
30 April 2025
After you have exposed the node and user resources you can first log in a user and perform an action with the session cookie returned. To keep the session cookie I am using some code from Roberto Rocco Angeloni:
http://www.roccoangeloni.it/wp/2008/06/13/xmlrpclib-with-cookie-aware-tr...
Then:
tr = CookieTransport()
server = xmlrpclib.Server(url, transport=tr)
server.system.connect()
user = server.user.login('user','password')
tr.SESSION_ID_STRING = user['session_name']
tr.mysessid = user['sessid']
new_node = {'body': 'Ordenar bibliotecas es ejercer de un modo silencioso el arte de la critica.\n-- Jorge Luis Borges. (1899-1986) Escritor argentino.', 'type': 'page', 'title': 'Just a little test'}
server.node.create(new_node)
server.node.retrieve(10)['uid']Help improve this page
Page status: Not set
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion