See introduction to XMLAPI for details on Authentication:

https://support.sippysoft.com/a/solutions/articles/106909

Python example - Digest Authentication

# this script requires httplib2 to be installed
# username should be Web Login of the Customer, password - API password
# 1.2.3.4 should be replaced with target IP/hostname of Sippy Softswitch
import httplib2
import urllib.request, urllib.parse, urllib.error
from xmlrpc.client import ServerProxy, getparser, ProtocolError

class HTTPSDigestAuthTransport:
    def request(self, host, handler, request_body, verbose=0):
        auth, host = urllib.parse.splituser(host)
        username, password = urllib.parse.splitpasswd(auth)

        h = httplib2.Http()
        if verbose:
            h.debuglevel = 1
        h.add_credentials(username, password)

        resp, content = h.request("https://" + host + handler, "POST", body=request_body,
                                  headers={'content-type':'text/xml'})

        if resp.status != 200:
            raise ProtocolError("https://" + host + handler,
                                resp.status, resp.reason, None)

        p, u = getparser(0)
        p.feed(content)

        return u.close()

transport = HTTPSDigestAuthTransport()
client = ServerProxy("https://username:password@1.2.3.4/xmlapi/xmlapi", transport)

# add a mapping
res = client.addCLIMapping({ 'i_account' : 1234, 'cli' : '123456', 'lang' : 'en' })
print(res['result'])

# retrieve list of trusted numbers
res = client.listCLIMappings({ 'i_account' : 1234 })
if res['result'] == 'OK':
    for cli, lang in res['list']:
        print(cli, lang)

Python example - Trusted Authentication

In this example i_customer should be supplied to selected XMLAPI method, which is mandatory for most methods in trusted mode. 


# this script requires httplib2 to be installed
# 1.2.3.4 should be replaced with target IP/hostname of Sippy 
import httplib2
import urllib.request, urllib.parse, urllib.error
from xmlrpc.client import ServerProxy, getparser, ProtocolError

class HTTPSTrustedAuthTransport:
    def request(self, host, handler, request_body, verbose=0):
        h = httplib2.Http(disable_ssl_certificate_validation=False)
        if verbose:
            h.debuglevel = 1
        resp, content = h.request(
            "https://" + host + handler,
            "POST",
            body=request_body,
            headers={'content-type': 'text/xml'})

        if resp.status != 200:
            raise ProtocolError("https://" + host + handler, resp.status,
                                resp.reason, None)
        p, u = getparser(0)
        p.feed(content)
        return u.close()

transport = HTTPSTrustedAuthTransport()
client = ServerProxy("https://1.2.3.4/xmlapi/xmlapi", transport)

# add a mapping
res = client.addCLIMapping({ 'i_customer': 1, 'i_account' : 34, 'cli' : '123456', 'lang' : 'en' })
print(res['result'])

# retrieve list of trusted numbers
res = client.listCLIMappings({ 'i_customer': 1, 'i_account' : 34 })
if res['result'] == 'OK':
    for cli, lang in res['list']:
        print(cli, lang)