-
Notifications
You must be signed in to change notification settings - Fork 88
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
Accessing the PayrollAuApi while connected to Demo Company gives an exception #340
Comments
Looking up the instance id shows that the access token you are using is missing the payroll.timesheets scope. Please can you go through the process of connecting your app to Xero and when you are generating the authorisation link, please can you add the payroll.timesheets scope to the list of scopes. When you reauthorise, the new scope will be added https://developer.xero.com/documentation/guides/oauth2/scopes |
hi, thanks for that, its working now |
Actually, i did manage to get it to work and did not get the original error of this issue. However I am now getting a 500 error. Here is the code:
try {
ApiClient defaultPayrollAuClient = new ApiClient("https://api.xero.com/payroll.xro/1.0",null,null,null,null);
// Get Singleton - instance of PayrollAUAPi client
PayrollAuApi payrollAuApi = PayrollAuApi.getInstance(defaultPayrollAuClient);
but when i run the code i get the followig :
GET Timesheets - total:11
GET one Timesheets - employee id:b6c19a95-27b0-4163-b4ec-a65949c44bb8
Employee=James Lebron
com.xero.api.XeroServerErrorException: An error occurred in Xero. Check the API Status page http://status.developer.xero.com for current service status.
at com.xero.api.XeroApiExceptionHandler.execute(XeroApiExceptionHandler.java:211)
at com.xero.api.client.PayrollAuApi.createTimesheet(PayrollAuApi.java:780)
at au.com.aquabubbler.lucille.xero.XeroTimesheetUploader.process(XeroTimesheetUploader.java:254)
at au.com.aquabubbler.lucille.tools.XeroTimesheetUploaderTester.main(XeroTimesheetUploaderTester.java:27)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61)
Caused by: com.google.api.client.http.HttpResponseException: 500 Internal Server Error
{"Title":"An error occurred","Detail":"An error occurred in Xero. Check the API Status page http://status.developer.xero.com for current service status.","Status":500,"Instance":"1a45aae2-fe1f-4092-ba85-86b392958aeb"}
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1070)
at com.xero.api.client.PayrollAuApi.createTimesheetForHttpResponse(PayrollAuApi.java:839)
at com.xero.api.client.PayrollAuApi.createTimesheet(PayrollAuApi.java:757)
The error is in the following line: everything up to that line worked ok, but somehow creating the timesheet gets me the 500 error. I am using the Demo Company, is it something that i am doing wrong? thanks |
The payload for the POST timesheet call is not quite correct as there is no pay period specified in the payload. https://developer.xero.com/documentation/api/payrollau/timesheets#post-timesheets |
SDK you're using (please complete the following information):
Versuin 4.14
Describe the bug
I have written code that connects to the Demo Company. I can create invoices without an issue. I now need to develop a timesheet application and i get an Unauthorized exception while conecting:
To Reproduce
Here is the code:
ApiClient defaultPayrollAuClient = new ApiClient("https://api.xero.com/payroll.xro/1.0",null,null,null,null);
// Get Singleton - instance of PayrollAUAPi client
PayrollAuApi payrollAuApi = PayrollAuApi.getInstance(defaultPayrollAuClient);
//GET all Timesheets
Timesheets timesheets = payrollAuApi.getTimesheets(access_token, xero_tenant_id, null, null, null, new Integer(1));
Expected behavior
I would expect this code to work because it is from an example
Additional context
Here is the error that i got:
com.xero.api.XeroUnauthorizedException: Unauthorized - check your scopes and confirm access to this resource
at com.xero.api.XeroApiExceptionHandler.execute(XeroApiExceptionHandler.java:173)
at com.xero.api.client.PayrollAuApi.getTimesheets(PayrollAuApi.java:2517)
at au.com.aquabubbler.lucille.xero.XeroTimesheetUploader.process(XeroTimesheetUploader.java:197)
at au.com.aquabubbler.lucille.tools.XeroTimesheetUploaderTester.main(XeroTimesheetUploaderTester.java:27)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61)
Caused by: com.google.api.client.http.HttpResponseException: 401 Unauthorized
{"Type":null,"Title":"Unauthorized","Status":401,"Detail":"AuthorizationUnsuccessful","Instance":"6df08333-14d6-4f26-be58-9e73a025e1c9","Extensions":{}}
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1070)
at com.xero.api.client.PayrollAuApi.getTimesheetsForHttpResponse(PayrollAuApi.java:2614)
at com.xero.api.client.PayrollAuApi.getTimesheets(PayrollAuApi.java:2505)
I am using the Demo company and from what i have read online, payroll suppose to be available when using the Demo Company. I dont see anywhere to configure the scopes for this object in the xero website.
Do you have any suggestions?
THanks
The text was updated successfully, but these errors were encountered: