pyxero
pyxero copied to clipboard
xero.exceptions.XeroBadRequest: PostDataInvalidException: The string 'False' is not a valid Boolean value.
def recode_account(xero,existing_code,new_code=None,**kwargs):
accounts = xero.accounts.filter(Code=existing_code)
account_id = accounts[0]['AccountID']
for (kwarg,value) in kwargs.items():
accounts[0][kwarg] = value
xero.accounts.save(accounts)
return accounts
accounts = recode_account(xero,existing_code='101000',new_code = '101000',Description='Test')
results in
xero.exceptions.XeroBadRequest: PostDataInvalidException: The string 'False' is not a valid Boolean value.
pyxero 0.8.0 in python 3.5.1
Possibly these two fields need to be included in BOOLEAN_FIELDS ShowInExpenseClaims EnablePaymentsToAccount
If I understand, I agree and think that there are several other fields that should be added to the Boolean Field list. If I do a simple "item = xero.items.get(productcode), then "item['Name']='New product name'", then xero.items.save(item), I get this same error message. Since Xero gave me "True" as a boolean, I shouldn't have to alter any other values in posting this back.
item = {u'ItemID': u'b5442fbe-e515-4913-aee4-e496a2e3bx33', u'Code': u'Prod2', u'Description': u'Demo Product Two', u'SalesDetails': {}, u'UpdatedDateUTC': datetime.datetime(2016, 8, 18, 18, 31, 6, 110000), u'IsPurchased': True, u'IsTrackedAsInventory': False, u'IsSold': True, u'PurchaseDetails': {}, u'ValidationErrors': []}
pyxero 0.8.0 in python 2.7.5
There are still some boolean Item fields which are missing from BOOLEAN_FIELDS tuple which cause this issue to occur. IsTrackedAsInventory
, IsSold
, IsPurchased
.
pyxero 0.9 in python 3.6.3
Pull request https://github.com/freakboy3742/pyxero/pull/205 created.