Open ari opened 8 years ago
I've discovered the specific cause of this problem. The filter should be 'PayRunStatus == POSTED' instead of with a single =.
I'll leave this open however. Is it possible for this library to return more helpful error messages, or is this all we get back from Xero?
having the same issue but even without filter.
Same issue its seen like an authentication problem in Xero's API. I've tried with differents methods.
I may find the error cause. I gues if you are using a trial account, maybe you doesnt have permission to retrive those informartions. You will need atleast "Standard or Advisor level user with the Payroll Admin permission set." According to the documentation API https://developer.xero.com/documentation/payroll-api/integration-guide
+1 on catching this error better.
I was trying to download attachments however hadn't added the XeroScopes.ACCOUNTING_ATTACHMENTS
scope.
Error was:
File "/usr/local/lib/python3.6/dist-packages/xero/exceptions.py", line 75, in __init__ self.errors = [payload["oauth_problem"][0]] KeyError: 'oauth_problem'
Adding the above scope fixed it.
For what it's worth, I have encountered a similar issue when making a request to the reports endpoint. Ex.
>>> trial_balance = self.xero.reports.get("TrialBalance")
KeyError: 'oauth_problem'
...truncated...
File "xero/client.py", line 000, in get_trial_balance_report
trial_balance = self.xero.reports.get("TrialBalance")
File "xero/basemanager.py", line 244, in wrapper
raise XeroUnauthorized(response)
File "xero/exceptions.py", line 75, in __init__
self.errors = [payload["oauth_problem"][0]]
In my case, I believe this was caused by a user who has authenticated with our application but has been assigned the "No Reports" role for that Xero Organisation as per the explanation in the Xero docs:
"An application that has been authorised by a Standard user with the "No reports" role will not be able to access the Reports or Journals endpoints (A HTTP 401 error will be returned in this case)." - https://developer.xero.com/documentation/api/reports
I think it's possible the 401 response from Xero, in this case, does not return a payload with "oauth_problem". We are still working on verifying this to be certain it is the cause.
+1 for catching these errors better.
+1 from me as well. I've got a response coming back with no oauth_problem
field, and I'm receiving the same KeyError
. In my case, it's also for reports:
report = client.reports.get('ProfitAndLoss', params={})
I'm doing some development against the sandbox account, so I suspect the underlying issue is permissions to retrieve reports. But would be nice to have a proper error message!
This isn't an oauth problem because "print xero.payrollAPI.payruns.all()" works fine. Can we get the exception giving us more detail about the specific request/response which Xero doesn't like?