Reputation: 11
I have used a tutorial and the Java SDK
to pull reports from the new REST reporting API
.
https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0201_ipp_java_devkit_3.0/reports
I have used the following code as specified by the tutorial:
String consumerKey = "XXXXXXXXXXXTDF2GEP0tlzdGxxpQRfSb4";
String consumerSecret = "XXXXXXXXXXYuy9CLaWiyAVHTowK0NuGMKN1X";
String accessToken = "XXXXXXXXXXXGPU4SUGAaeyhRJFp05NUg4s8QnbY4eI4U";
String accessTokenSecret = "XXXXXXXXXXXgkz50A8Ho3Z3pgMO8QFh2ZBv3XjI";
OAuthAuthorizer oauth = new OAuthAuthorizer(consumerKey, consumerSecret, accessToken, accessTokenSecret);
String appToken = "011e510ebf68ab4683b8a06b21f6228dfa03";
String companyID = "1067363490";
try {
Context context = new Context(oauth, appToken, ServiceType.QBO, companyID);
ReportService service = new ReportService(context);
service.setStart_date("2014-02-01");
service.setEnd_date("2014-04-20");
service.setAccounting_method("Accrual");
Object report = service.executeReport(ReportName.PROFITANDLOSS.toString());
String name = "ryan";
//System.out.println(report.toString());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Inside service.executeReport
it keeps throwing a java.lang.ClassCastException
: com.intuit.ipp.data.Report
cannot be cast to com.intuit.ipp.core.Response
Has anyone got these reports to work with the Java SDK
? Am I doing something wrong?
Upvotes: 1
Views: 170
Reputation: 1
Update Line:
Object report = service.executeReport(ReportName.PROFITANDLOSS.toString());
To:
Report report = service.executeReport(ReportName.PROFITANDLOSS.toString());
As shown here: https://developer.intuit.com/docs/0100_accounting/0500_developer_kits/0201_ipp_java_devkit_3.0/reports
Upvotes: 0
Reputation: 2367
At present reports support only Json. Please verify that you are specifying: Config.setProperty(Config.SERIALIZATION_RESPONSE_FORMAT, "json");
Upvotes: 1