So I started to learn python and I would like to make this little script,
goal is to get wan Ip from my router using UPnP, so I got this code, actualy Im find this code on web and now Im trying to adopt it

    import os
    from SOAPpy import *
    ## "endpoint" is the control URL for WANPPPConnection on a Speedtouch 510
    endpoint = ""
    namespace = "urn:schemas-upnp-org:service:WANPPPConnection:1"
    soapaction = "urn:schemas-upnp-org:service:WANPPPConnection:1#GetExternalIPAddress"
    server = SOAPProxy(endpoint, namespace)
    print "external IP", server._sa(soapaction).GetExternalIPAddress()
But it does not corespond to my situation, UPnP service on my router is seted up diferently so I need to make some changes
here is one part of setup configs from IGD.xml from my router in which Im interested in as example


as u can see diference is in control url in mine case ? is used betwen control and WAN "string" and in code above / is used and heres are mine changes

import os
    import xml
    from SOAPpy import *

    endpoint = ""
    namespace = "urn:schemas-upnp-org:service:WANPPPConnection1"
    soapaction = "urn:upnp-org:serviceId:WANPPPConn1#GetExternalIPAddress"

    server = SOAPProxy(endpoint, namespace)
    print "external IP", server._sa(soapaction).ExternalIPAddress()

but I can not run this at all, and here is error that Im geting

Code: Select all
    Traceback (most recent call last):
      File "", line 11, in <module>
        print "external IP", server._sa(soapaction).ExternalIPAddress()
      File "/usr/lib/pymodules/python2.7/SOAPpy/", line 470, in __call__
        return self.__r_call(*args, **kw)
      File "/usr/lib/pymodules/python2.7/SOAPpy/", line 492, in __r_call
        self.__hd, self.__ma)
      File "/usr/lib/pymodules/python2.7/SOAPpy/", line 406, in __call
        raise p
    SOAPpy.Types.faultType: <Fault s:Client: UPnPError: <SOAPpy.Types.structType detail at 3068858060>: {'UPnPError': <SOAPpy.Types.structType UPnPError at 3068858092>: {'errorCode': '401', 'errorDescription': 'Invalid Action'}}>
Is there any chances thet someone can help me to correct this error tnx