Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add in the PUT type to create new TaxRates #872

Merged
merged 1 commit into from
Oct 10, 2022
Merged

Add in the PUT type to create new TaxRates #872

merged 1 commit into from
Oct 10, 2022

Conversation

mogilvie
Copy link
Contributor

@mogilvie mogilvie commented Oct 2, 2022

Was not able to create new tax types (although this used to work sometime ago) Added in the PUT type as per the documentation and now my original code works again.

API link here. https://developer.xero.com/documentation/api/accounting/taxrates

Was not able to create new tax types (although this used to work sometime ago)
Added in the PUT type as per the documentation and now my original code works again.

API link here. https://developer.xero.com/documentation/api/accounting/taxrates
@mogilvie
Copy link
Contributor Author

mogilvie commented Oct 2, 2022

Note that the PUT method was removed in cbd03cf because the POST is supposed to work for creating tax rates.

However, when you post the same content to Xero it tries to modify an existing tax rate, even when the names don't match. And if the number of TaxComponents in the existing (but differently named) TaxRate don't match the submitted TaxComponent count, then you get the error below.

POST not working:
image

The Xero API is finding the first available existing TaxRate, then comparing the number of TaxComponents and firing the error.

As a test, I also posted a new tax rate without tax components, and the POST overwrote the name of an existing (and unrelated) TaxRate.

Using PUT works:
image

@calcinai calcinai merged commit 563d152 into calcinai:master Oct 10, 2022
@calcinai
Copy link
Owner

LGTM, this kind of thing has been really inconsistent in the API over the years

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants