Search code examples
pythondjangosoapzeepsolarwindslem

SolarWinds N-central 5000 Query failed using zeep


I am trying to add Customer using zeep in Python3 in N-central Solarwind and getting error 5000 Query failed.

def addcustomer(request):
client = Client('http://server-name.com/dms/services/ServerEI?wsdl')
settings_type=client.get_type('ns0:T_KeyPair')
value = settings_type(
    'customer_name','id_'
    )
response =client.service.CustomerAdd(Username=USER,Password=PASS, Settings=value)
return render(request,'ncentral/addcustomer.html',locals())

And if I try to give 1 more parameter in settings like this

value = settings_type(
        'customer_name','123','pin_code'
        )

I get error

init() takes at most 2 positional arguments (3 given)

I think I am sending data in the wrong format

This is what is written in Docs

int customerAdd(String username,
String password,
List settings)
throws RemoteException
Adds a new Customer or Site to the MSP N-central.
Parameters:
username - the MSP N-central username.
password - the Corresponding MSP N-central password.
settings - A list of settings stored in a List of EiKeyValue objects. Below is a list of the acceptable keys and values.
Mandatory (Key) customername - (Value) Desired name for the new customer or site. Maximum of 120 characters.
Mandatory (Key) parentid - (Value) the (customer) id of the parent service organization or parent customer for the new customer/site.
(Key) zip/postalcode - (Value) Customer's zip/ postal code.
(Key) street1 - (Value) Address line 1 for the customer. Maximum of 100 characters.
(Key) street2 - (Value) Address line 2 for the customer. Maximum of 100 characters.
(Key) city - (Value) Customer's city.
(Key) state/province - (Value) Customer's state/ province.
(Key) telephone - (Value) Phone number of the customer. (Key) country - (Value) Customer's country. Two character country code, see http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 for a list of country codes.
(Key) externalid - (Value) An external reference id.
(Key) firstname - (Value) Customer contact's first name.
(Key) lastname - (Value) Customer contact's last name.
(Key) title - (Value) Customer contact's title.
(Key) department - (Value) Customer contact's department.
(Key) contact_telephone - (Value) Customer contact's telephone number.
(Key) ext - (Value) Customer contact's telephone extension.
(Key) email - (Value) Customer contact's email. Maximum of 100 characters.
(Key) licensetype - (Value) The default license type of new devices for the customer. Must be "Professional" or "Essential". Default is "Essential".


Solution

  • The format was wrong following code worked for me

    def addcustomer(request):
        client = Client('http://server-name/dms/services/ServerEI?wsdl')
        value = [
            {
                'Key': 'customername',
                'Value': 'testing'
            },
            {
                'Key': 'parentid',
                'Value': '123'
            },
        ]
        response = client.service.CustomerAdd(Username=USER, Password=PASS, Settings=value)
        return render(request, 'ncentral/customeradd.html', locals())