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

Error with AccountingApi.getJournals endpoint #412

Closed
TheWass opened this issue Apr 30, 2020 · 4 comments
Closed

Error with AccountingApi.getJournals endpoint #412

TheWass opened this issue Apr 30, 2020 · 4 comments
Assignees
Labels
Priority: High Status: Accepted Assigned to contributor

Comments

@TheWass
Copy link

TheWass commented Apr 30, 2020

SDK you're using (please complete the following information):

  • Version 4.5.1

Describe the bug
An error occurs when calling getJournals on the accountingApi object.

TypeError: data.substring is not a function
    at Function.deserialize (/../../node_modules/xero-node/dist/gen/model/accounting/models.js:514:43)

To Reproduce
Steps to reproduce the behavior:

  1. clone, configure, and run https://github.com/XeroAPI/xero-node-oauth2-app
  2. Sign into Xero with the Demo Company (US)
  3. Click the 'Journals' link on the left-hand menu
  4. Observe the crash.

Expected behavior
It should return the requested journal entries.

Additional context
I did a little investigation: The JournalNumber is the culprit. It comes down as a number, rather than a string. Since it is a number, it does not have the substring function, causing the error. It looks like this is generated code, so I don't know if a pull request would help, but I'd be happy to make one.

@SerKnight
Copy link
Contributor

Thanks @TheWass - good find. You are correct that is generated code!

I will duplicate this to get a fix in asap. Mid next week expect a reply to this threa.

@SerKnight
Copy link
Contributor

Got a PR up for this. Need to ensure it does not cause issues across other SDK's but next week (mid-week) will be deployed NPM and in master.

XeroAPI/Xero-OpenAPI#201
https://github.com/XeroAPI/xero-node/pull/413/files#diff-a499fe0092003ea56fc33513d5d1c618R27

@LiamKarlMitchell
Copy link

Same problem in sample app when clicking banktransfers.

            if (type === "string" && data.substring(0, 6) === "/Date(") {
                                          ^
TypeError: data.substring is not a function
    at Function.deserialize (C:\dev\xero-node-oauth2-app\node_modules\xero-node\dist\gen\model\accounting\models.js:514:43)
    at Function.deserialize (C:\dev\xero-node-oauth2-app\node_modules\xero-node\dist\gen\model\accounting\models.js:547:65)
    at Function.deserialize (C:\dev\xero-node-oauth2-app\node_modules\xero-node\dist\gen\model\accounting\models.js:529:55)
    at Function.deserialize (C:\dev\xero-node-oauth2-app\node_modules\xero-node\dist\gen\model\accounting\models.js:547:65)
    at Request._callback (C:\dev\xero-node-oauth2-app\node_modules\xero-node\dist\gen\api\accountingApi.js:5650:62)
    at Request.self.callback (C:\dev\xero-node-oauth2-app\node_modules\request\request.js:185:22)
    at Request.emit (events.js:305:20)
    at Request.EventEmitter.emit (domain.js:483:12)
    at Request.<anonymous> (C:\dev\xero-node-oauth2-app\node_modules\request\request.js:1154:10)
    at Request.emit (events.js:305:20)```

@SerKnight
Copy link
Contributor

Thanks all - fixed in recent release of #415 as version 4.5.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: High Status: Accepted Assigned to contributor
Projects
None yet
Development

No branches or pull requests

3 participants