adamvalcato Posted August 5, 2010 Share Posted August 5, 2010 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? 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted August 5, 2010 Share Posted August 5, 2010 What does your code look like? Are you passing at least blank values for the address? 0 Quote Link to comment Share on other sites More sharing options...
adamvalcato Posted August 5, 2010 Author Share Posted August 5, 2010 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: 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) 0 Quote Link to comment Share on other sites More sharing options...
MACscr Posted May 4, 2011 Share Posted May 4, 2011 Where you ever able to get around those fields being required? Seems kind of crazy for whmcs to force this on us. 0 Quote Link to comment Share on other sites More sharing options...
adamvalcato Posted May 4, 2011 Author Share Posted May 4, 2011 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). 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.