0

I have one application in java and I use the XERO invoicing gateway (https://xero.com), in the next version:

<dependency>
    <groupId>com.github.xeroapi</groupId>
    <artifactId>xero-java</artifactId>
    <version>2.1.3</version>
</dependency>

To configure the private application in xerp, I use the code:

try {
    Config config = JsonConfig.getInstance();       
    System.out.println("Your user agent is: " + config.getUserAgent());         
} catch(Exception e) {
    System.out.println(e.getMessage());
}

(available in https://github.com/XeroAPI/Xero-Java)

My question is: is it possible to specific the absolute path to configuration file (config.json) ?

Thanks all

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
roliveira
  • 87
  • 1
  • 12

1 Answers1

1

The JsonConfig class looks for the config.json file inside a "resources" folder. If that doesn't work for your server environment, you can implement your own version of the JsonConfig class and utilize that.

Here is an example ... https://github.com/XeroAPI/Xero-Java/blob/master/src/main/java/com/xero/example/CustomJsonConfig.java

Then test in a try block that you can read the user-agent correctly.

try {
    config = new CustomJsonConfig();
    System.out.println("Your user agent is: " + config.getUserAgent());         
} catch(Exception e) {
    System.out.println(e.getMessage());
}

ApiClient apiClientForAccounting = new 
ApiClient(config.getApiUrl(),null,null,null);

AccountingApi accountingApi = new AccountingApi(config);
accountingApi.setApiClient(apiClientForAccounting);
accountingApi.setOAuthToken(token, tokenSecret);