Question

I', using IPP java QBO ApiV3. I able to read and query customer via API Explorer, IPP Playground and my Java app.

I can not create customer (or update existing one) via IPP Playground and my Java App. However, I am able to create and update via API Explorer. I am confused that I am getting different errors in IPP Playground (500 - Internal server error.) and Java app (message=Exception authenticating OAuth; errorCode=003200).

Authentication part is same as in method that reads Customer. In addition I only attach the Request Body (same as in API Explorer) to the request.

Java Code:

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

String signedUrl = consumer.sign(custUrl);
URL url = new URL(signedUrl);

String requestBody = " <Customer xmlns=\"http://schema.intuit.com/finance/v3\" domain=\"QBO\" sparse=\"false\">"+
                     "    <FamilyName>Customer Two</FamilyName>"+
                     "    <DisplayName>Second Customer</DisplayName>"
                     " </Customer>";

HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
urlConn.setDoOutput(true);
urlConn.setDoInput(true);
// add Request Header
urlConn.setRequestMethod("POST");
urlConn.setRequestProperty("Content-type", "application/xml");
urlConn.setRequestProperty("Content-Length", Integer.toString(requestBody.getBytes().length));
urlConn.setRequestProperty("Host", "qb.sbfinance.intuit.com");
urlConn.setRequestProperty("Accept-Encoding", "gzip,deflat");
urlConn.setRequestProperty("charset", "utf-8");

OutputStreamWriter wr = new OutputStreamWriter(urlConn.getOutputStream());
wr.write(requestBody);
wr.flush();
wr.close();

Any idea how to resolve this?

Was it helpful?

Solution

All these concerns are already handled by JAVA devkit.

https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits

https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0201_ipp_java_devkit_3.0/0001_synchronous_calls/0001_data_service_apis

Re - your code Accept should be 'application/xml'

But devkit is always the recommended approach.

Thanks

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top