0
votes

How do I retrieve an invoice from Quickbooks Online using the Java SDK? I'm currently migrating from oAuth 1.0 to 2.0 and the library upgrades have removed the methods I had previously been using to retrieve an invoice in PDF format. The new libraries I'm using are:

  • oauth2-platform-api-6.0.2
  • ipp-v3-java-devkit-6.0.2
  • ipp-v3-java-data-6.0.2

Previously, I had been doing something like this:

OAuthConsumer consumer = new DefaultOAuthConsumer(consumerKey, consumerSecret);
consumer.setTokenWithSecret(accessToken, accessTokenSecret);  

String urlStr = String.format(
    "https://quickbooks.api.intuit.com/v3/company/%s/invoice/%s/pdf", realmId, invoiceId);

URL url = new URL( urlStr );
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("Accept", "application/pdf");
connection.setUseCaches(false);

consumer.sign(connection);
connection.connect();

...but OAuthConsumer is gone now. Is there some replacement for this that I can use to sign the request, or alternatively is there someway to do it with the DataService object?

1

1 Answers

0
votes

You can sign your request in the same way using oAuth2 with the OAuth2Authorizer object e.g.

URL url = new URL(urlStr);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
OAuth2Authorizer oauth = new OAuth2Authorizer(accessToken);
oauth.authorize(connection);