question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't save objects to xero.

See original GitHub issue

I try to do this

contacts = xero_client.contacts.all()
for contact in contacts:
    if contact.get("Name") == supplier_name:
        contact["Addresses"][0]["City"] = "Manhattan"
        xero_client.contacts.save(contact)

# HERE I am trying to mark the invoice as paid.
invoices = xero_client.invoices.get(invoice_number)
for invoice in invoices:
    if invoice.get("Contact").get("Name") == supplier_name:
        invoice["Status"] = "PAID"
        xero_client.invoices.save(invoice)        

but it’s throwing this error in both cases.

  xero_client.contacts.save(contact)
  File "/Library/Python/2.7/site-packages/xero/manager.py", line 187, in wrapper
    raise XeroBadRequest(response)
  File "/Library/Python/2.7/site-packages/xero/exceptions.py", line 24, in __init__
    for elem in data['Elements']
    KeyError: 'Elements'

can someone please help me solve this.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
aidanlistercommented, Apr 6, 2020

If someone makes a PR I’ll merge it

0reactions
peircejcommented, Apr 6, 2020

There’s actually a further issue with (at least one of) the date fields because when the above issue was fixed the API then complained about the date being in the wrong format. Re-saving the datetime to a simple date (in my script not in pyxero) fixed that problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues importing inventory items or opening balances
See why you might be getting an error when you try to import inventory items or opening balances into Xero.
Read more >
Fix problems with importing and exporting invoices
In the Business menu, select Invoices. · Select the Xero Export Failed tab. · Select the checkbox next to one or more invoices...
Read more >
i am trying to add a contact but there is no save button
I am trying to add a new contact so I can invoice them but when i put in all the details there is...
Read more >
Import inventory items into Xero
In the Business menu, select Products and services. · Click Import, then select Items. · Under Upload items, click Select file to locate...
Read more >
Why wont my invoices auto save? - Xero Central
not the answer I was looking for, normally when I'm creating an invoice it auotsaves but occasionally it won't. There has to be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found