xero-python icon indicating copy to clipboard operation
xero-python copied to clipboard

Unable to proceed with TypeError: update_token() argument after ** must be a mapping, not str

Open bishwadeep opened this issue 4 years ago • 0 comments

Hey guys, I need help as I am not able to resolve this issue for so long. Now I am stuck in the last function, Any help would be really appreciated. I used the code from here: https://github.com/XeroAPI/xero-python-custom-connections-starter/issues/1 to get the tocken. `` Traceback (most recent call last): File "", line 1, in File "/code/providers/xero_invoice.py", line 308, in invoiceGetActiveProviders results = accounting_api.create_invoices(xero_tenant_id, invoice, True) File "/usr/local/lib/python3.7/site-packages/xero_python/accounting/api/accounting_api.py", line 2493, in create_invoices collection_formats=collection_formats, File "/usr/local/lib/python3.7/site-packages/xero_python/api_client/init.py", line 365, in call_api _request_timeout, File "/usr/local/lib/python3.7/site-packages/xero_python/api_client/init.py", line 186, in __call_api self.update_params_for_auth(header_params, query_params, auth_settings) File "/usr/local/lib/python3.7/site-packages/xero_python/api_client/init.py", line 579, in update_params_for_auth auth_setting = auth_setting(api_client=self) File "/usr/local/lib/python3.7/site-packages/xero_python/api_client/oauth2.py", line 176, in create_auth_settings self.update_token(**api_client.get_oauth2_token()) TypeError: update_token() argument after ** must be a mapping, not str

Here is the code: I have a custom connection setup in the xero. I have setup the app and collected the client id and client secret. I have a cron job file which push the invoice. So, I dont want to use flask. I am able to get the token. The error is when I run accounting_api.create_invoices(xero_tenant_id, invoice, True) `` def invoiceGetActiveProviders(): xero_tenant_id = "Replaced by my tenant id" xero_client = ApiClient( Configuration( debug=False, oauth2_token=OAuth2Token( client_id="REPLACED BY CLIENT ID WORKING FINE", client_secret="REPLACED BY SECRET WORKING FINE" ), ), pool_threads=1, ) accounting_api = AccountingApi(xero_client) #my oauth v1 code to create invoice invoice = '[{'Type': 'ACCREC', 'Contact': {'ContactID': 'REPLACED BY CONTACT ID'}, 'Date': datetime.datetime(2021, 12, 1, 18, 50, 52, 587675), 'DateString': '2021-11-30 18:50:52', 'Reference': 'Nov 2021 Leads', 'DueDate': datetime.datetime(2022, 1, 2, 18, 50, 52, 587668), 'DueDateString': '2022-01-02 18:50:52', 'CurrencyCode': 'AUD', 'LineItems': [{'Description': 'CareerFAQs.com.au AUS Lead', 'Quantity': 1, 'UnitAmount': 65.0, 'AccountCode': '41000', 'ItemCode': '1060'}]}]'

accounting_api.create_invoices(xero_tenant_id, invoice, True) ``

bishwadeep avatar Dec 19 '21 08:12 bishwadeep