Xero API not working

So I have migrated from my spring app to using Cuba. I use an accounting software called Xero which I need to link to but for some reason it is not working with Cuba. I don’t really know where to begin looking for the problem…

I have followed the guide for “Spring Based Config” here https://github.com/XeroAPI/Xero-Java

The bean that is created is this:

@Configuration
@PropertySource("classpath:/com/daryn/ecosmart/xero.properties")
public class XeroBean {

    @Autowired
    private Environment environment;

@Bean
    public XeroClient xeroClient(Environment environment) {
        SpringConfig config = new SpringConfig("xero.", environment);
        XeroClient client = new XeroClient(config);
        client.setOAuthToken(config.getConsumerKey(), config.getConsumerSecret());
        return client;
    }

The error I keep getting when I try to use the bean is this:

java.lang.AbstractMethodError: com.daryn.ecosmart.service.XeroSpringConfig.getConnectTimeout()I
at com.xero.api.OAuthRequestResource.init(OAuthRequestResource.java:109) ~[xero-java-sdk-0.4.7.jar:na]
at com.xero.api.OAuthRequestResource.(OAuthRequestResource.java:123) ~[xero-java-sdk-0.4.7.jar:na]
at com.xero.api.XeroClient.get(XeroClient.java:180) ~[xero-java-sdk-0.4.7.jar:na]
at com.xero.api.XeroClient.get(XeroClient.java:174) ~[xero-java-sdk-0.4.7.jar:na]

I don’t know too much about what is going on in the backend here - way beyond my knowledge level. All I know is that the exact same program works in my Spring app but not in Cuba for some reason…

Hi,

not a direct answer to your question, however it might be interesting for you:

I created a CUBA <–> Xero integration a while ago. You can take a look at it here: https://github.com/mariodavid/cuba-example-xero-api-integration

Note, that I didn’t use the now official Xero client, but another one instead: https://github.com/benmccann/xero-java-client. The official one was not really mature enough back then.

Bye
Mario

Have tried your program. I get the following error when clicking the Download Invoices Button

java.lang.NullPointerException: null
at com.connectifier.xeroclient.oauth.XeroOAuthService.(XeroOAuthService.java:32) ~[client-0.13.jar:0.13]
at com.connectifier.xeroclient.XeroClient.(XeroClient.java:74) ~[client-0.13.jar:0.13]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_121]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_121]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_121]

Actually I have it working now. Had the key file in the wrong format.

Can you create a xero contact with that API?