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

ApiExceptions result in parse error #557

Open
canavese opened this issue Jan 29, 2022 · 0 comments
Open

ApiExceptions result in parse error #557

canavese opened this issue Jan 29, 2022 · 0 comments

Comments

@canavese
Copy link

canavese commented Jan 29, 2022

When an ApiException is returned by the Xero API, a parsing exception occurs, apparently because it is expecting JSON but getting XML.

It's happening at lib/xeroizer/http_response.rb, line 130:

    def raise_error!
      begin
        error_details = JSON.parse(response.plain_body)

This is the exception that gets raised:

unexpected token at '<ApiException xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ErrorNumber>10</ErrorNumber>
  <Type>ValidationException</Type>
  <Message>A validation exception occurred</Message>
  <Elements>
    <DataContractBase xsi:type="Invoice">
      <ValidationErrors>
        <ValidationError>
          <Message>Invoice not of valid status for modification</Message>
        </ValidationError>
        <ValidationError>
          <Message>This document cannot be edited as it has a payment or credit note allocated to it.</Message>
        </ValidationError>
      </ValidationErrors>
...

Thanks!

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

No branches or pull requests

1 participant