Results 1 to 5 of 5

Thread: API: Address required for addclient?

  1. #1

    Default API: Address required for addclient?

    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?

  2. #2
    Join Date
    Feb 2009
    Location
    Atlanta, GA
    Posts
    1,683

    Default

    What does your code look like? Are you passing at least blank values for the address?

  3. #3

    Default

    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):

    Code:
    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:
                        out.update({pair[0]:pair[1]})
            
            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:
                    kwargs.update({k:v})
                    
            for k in blank_defaults:
                if not k in kwargs:
                    kwargs.update({k:'-'})
    
            return self.execute('addclient', kwargs)

  4. #4
    Join Date
    May 2006
    Posts
    2,530

    Default

    Where you ever able to get around those fields being required? Seems kind of crazy for whmcs to force this on us.
    DISCLAIMER: I am in no way associated with WHMCS. My statements only come from years of programming, experience using WHMCS, and just my honest opinion.

  5. #5

    Default

    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).

Similar Threads

  1. API call "addclient": How to set Tax exempt?
    By tusker in forum Customisation & Integration Questions
    Replies: 3
    Last Post: 09-27-12, 01:34 PM
  2. Email Address - Required Field, Can I Disable?
    By gobbly2100 in forum General Discussion
    Replies: 1
    Last Post: 03-17-10, 05:37 PM
  3. UpdateClient and AddClient API Do Not work
    By DaveK in forum Customisation & Integration Questions
    Replies: 0
    Last Post: 07-29-09, 04:36 AM
  4. How to add a session in addclient API function
    By nuwaninfo in forum Customisation & Integration Questions
    Replies: 0
    Last Post: 03-11-09, 09:42 AM
  5. Does not work addclient in API
    By nuwaninfo in forum Customisation & Integration Questions
    Replies: 3
    Last Post: 03-05-09, 06:08 AM