Jump to content

API: Address required for addclient?


Recommended Posts

In WHMCS I can create clients with just their name and email address, but when using the API it seems the address is also required. I get:


You did not enter your address (line 1)


I guess I can just set the required fields to dummy values, but is this a bug in the API or is this the intended behaviour?

Link to comment
Share on other sites

I've tried setting the address to the empty string and a single space (and also after testing it seems city, state, postcode and phonenumber are also required). Neither of those worked, so I'm now just setting them to '-', which does work but is kind of ugly.


Also, the API docs imply that the welcome email will be sent automatically unless noemail=true, but that doesn't seem to be the case. (Setting noemail=false doesn't make a difference.)


Here's an excerpt from my code if you're interested (this is in Python):


class WHMCS:

   def execute(self, action, args):
       args.update({'username': self.user, 'password': self.password, 'action': action})
       params = urllib.urlencode(args)

       result = urllib.urlopen(self.url, params).read()

       out = dict()

       for field in result.split(';'):
           if len(field) > 0:
               pair = field.split('=', 1)
               if len(pair) == 2:

       if out['result'] == 'error':
           raise WHMCSAPIException(out['message'])

       return out

   def addclient(self, firstname, lastname, email, **kwargs):
       kwargs.update({'firstname': firstname, 'lastname': lastname, 'email': email})

       defaults = {'password2': random_password()}
       blank_defaults = ['address1', 'city', 'state', 'postcode', 'phonenumber']

       for (k,v) in zip(defaults.keys(), defaults.values()):
           if not k in kwargs:

       for k in blank_defaults:
           if not k in kwargs:

       return self.execute('addclient', kwargs)

Link to comment
Share on other sites

  • 8 months later...

In the end I had to just have my code set all the address fields to "-" so that they wouldn't be empty. It's a little ugly, but it's the best way I could find (I tried just setting it to a space, but WHMCS seems to strip away whitespace so that didn't work).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated