pyxero icon indicating copy to clipboard operation
pyxero copied to clipboard

xero.exceptions.XeroBadRequest: PostDataInvalidException: The string 'False' is not a valid Boolean value.

Open timrichardson opened this issue 8 years ago • 4 comments

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

timrichardson avatar May 09 '16 12:05 timrichardson

Possibly these two fields need to be included in BOOLEAN_FIELDS ShowInExpenseClaims EnablePaymentsToAccount

timrichardson avatar May 09 '16 13:05 timrichardson

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

randyshaw avatar Aug 18 '16 21:08 randyshaw

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

sdolemelipone avatar Dec 23 '17 12:12 sdolemelipone

Pull request https://github.com/freakboy3742/pyxero/pull/205 created.

sdolemelipone avatar Dec 23 '17 13:12 sdolemelipone