Writing a Python program to access services

Discussion in 'ISPConfig 3 Priority Support' started by Turgut Kalfaoglu, Jan 24, 2025.

  1. Turgut Kalfaoglu

    Turgut Kalfaoglu Member HowtoForge Supporter

    I'm working on a python program to search and replace for an IP address in the DNS tables and replace it with something else. But I'm stuck at the first hurdle. I can't login :)
    Code:
    server = xmlrpc.client.ServerProxy(ISP_CONFIG_URL)
    try:
       # Authenticate
       session_id = server.login(ISP_CONFIG_USER, ISP_CONFIG_PASSWORD)
       print("Successfully connected to ISPCONFIG Remote API!")
       print("Session ID:", session_id)
       sys.exit(1)
    except Exception as e:
       print("Failed to connect to ISPCONFIG Remote API:", e)
       sys.exit(1)
    
    It always gives an Failed to connect to ISPCONFIG Remote API: <ProtocolError for server.kalfa.uk:8080/remote/index.php: 500 Internal Server Error>
    I can telnet to that port, so it's listening, and credentials are correct, permissions of the remote user I picked are full, so I don't know why I get an error 500. I also couldn't find anything in the system logs..
    Many thanks, -t
     
    Last edited: Jan 24, 2025
  2. pyte

    pyte Well-Known Member HowtoForge Supporter

    I'd recommend using a php script to do whatever you want to do. The API is well documented with PHP examples.
     
  3. till

    till Super Moderator Staff Member ISPConfig Developer

    I'm not a Python coder, but it seems you are trying to use XMLRPC, but ISPConfig does not provide an XML-RPC API. You can either use the SOAP API or the REST API from ISPConfig. But as @pyte mentioned, there are plenty of examples in PHP, so using PHP is probably easier.
     

Share This Page